Enable skipping tests based on --reactor.

This commit is contained in:
Andrey Rakhmatullin 2019-12-16 19:24:25 +05:00
parent a1605cade6
commit 2db7d45378
2 changed files with 10 additions and 0 deletions

View File

@ -35,6 +35,14 @@ def pytest_collection_modifyitems(session, config, items):
except ImportError:
pass
@pytest.fixture()
def reactor_pytest(request):
request.cls.reactor_pytest = request.config.getoption("--reactor")
return request.cls.reactor_pytest
@pytest.fixture(autouse=True)
def only_asyncio(request, reactor_pytest):
if request.node.get_closest_marker('only_asyncio') and reactor_pytest != 'asyncio':
pytest.skip('This test is only run with --reactor-asyncio')

View File

@ -19,6 +19,8 @@ addopts =
--ignore=docs/topics/telnetconsole.rst
--ignore=docs/utils
twisted = 1
markers =
only_asyncio: marks tests as only enabled when --reactor=asyncio is passed
flake8-ignore =
# Files that are only meant to provide top-level imports are expected not
# to use any of their imports: