Search code examples
python-3.xtornadopytestcoroutine

How to properly replace @pytest.mark.gen_test after pytest upgrade to 4.0.2?


I have tornado co-routines tests that passed under pytest 3.8.2, but recently I've upgraded to 4.0.2 and now I get these tests failed with the following message.

    @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

I looked the url suggested and tried to search the web, but unfortunately could figure out nothing by myself.

Tests use @pytest.mark.gen_test decorator.

So, could anyone shed some light on this? How to make these tests pass again?


Solution

  • The issue related to pytest-tornado that I replaced with pytest-tornado-yen3==0.5.2, but unfortunately pytest started crashing with ImportError: No module named 'pytest_tornado'

    Eventually I ended up with this.

    pip3 uninstall pytest-tornado-yen3 pytest-tornado pytest
    pip3 install pytest-tornado-yen3==0.5.2 pytest==4.0.2 
    

    And the issue is gone now.