pytest升级到4.0.2后如何正确替换@ pytest.mark.gen_test?

时间:2019-03-15 13:50:08

标签: python-3.x tornado pytest coroutine

我有在pytest 3.8.2下通过的龙卷风协同例程测试,但是最近我已经升级到4.0.2,现在我得到这些测试失败,并显示以下消息。

    @pytest.mark.tryfirst
    def pytest_pyfunc_call(pyfuncitem):
        gen_test_mark = pyfuncitem.keywords.get('gen_test')
        if gen_test_mark:
            io_loop = pyfuncitem.funcargs.get('io_loop')
>           run_sync = gen_test_mark.kwargs.get('run_sync', True)
E           _pytest.warning_types.RemovedInPytest4Warning: MarkInfo objects are deprecated as they contain merged marks which are hard to deal with correctly.
E           Please use node.get_closest_marker(name) or node.iter_markers(name).
E           Docs: https://docs.pytest.org/en/latest/mark.html#updating-code

/usr/local/lib/python3.5/dist-packages/pytest_tornado/plugin.py:98: RemovedInPytest4Warning

我查看了建议的网址,并尝试在网上搜索,但不幸的是我自己一无所获。

测试使用@pytest.mark.gen_test装饰器。

那么,有人能对此有所启发吗?如何使这些测试再次通过?

1 个答案:

答案 0 :(得分:0)

我用CREATE PROC TableMaxCount @Table sysname, @Column sysname, @Value int AS BEGIN DECLARE @SQL nvarchar(MAX); SELECT @SQL = N'SELECT MAX(' + QUOTENAME(c.[name]) + NCHAR(13) + NCHAR(10) + N'FROM ' + QUOTENAME(t.[name]) + NCHAR(13) + NCHAR(10) + N'WHERE ' + QUOTENAME(c.[name]) + N' = @Value;' FROM sys.tables t JOIN sys.columns c ON t.object_id = c.object_id JOIN sys.schemas s ON t.schema_id = s.schema_id WHERE t.[name] = @Table AND c.[name] = @Column AND s.[name] = N'dbo'; --Assumes always dbo schema EXEC sp_executesql @SQL, N'@Value int', @Value = @Value; END 代替了与pytest-tornado相关的问题,但不幸的是pytest-tornado-yen3==0.5.2开始因pytest崩溃

最终我结束了这个。

ImportError: No module named 'pytest_tornado'

问题已经解决了。