diff --git a/testing/conftest.py b/testing/conftest.py new file mode 100644 index 000000000..fb677cd05 --- /dev/null +++ b/testing/conftest.py @@ -0,0 +1,26 @@ +def pytest_collection_modifyitems(config, items): + """Prefer faster tests.""" + fast_items = [] + slow_items = [] + neutral_items = [] + + slow_fixturenames = ("testdir",) + + for item in items: + try: + fixtures = item.fixturenames + except AttributeError: + # doctest at least + # (https://github.com/pytest-dev/pytest/issues/5070) + neutral_items.append(item) + else: + if any(x for x in fixtures if x in slow_fixturenames): + slow_items.append(item) + else: + marker = item.get_closest_marker("slow") + if marker: + slow_items.append(item) + else: + fast_items.append(item) + + items[:] = fast_items + neutral_items + slow_items diff --git a/testing/test_modimport.py b/testing/test_modimport.py index 33862799b..3d7a07323 100644 --- a/testing/test_modimport.py +++ b/testing/test_modimport.py @@ -6,6 +6,8 @@ import py import _pytest import pytest +pytestmark = pytest.mark.slow + MODSET = [ x for x in py.path.local(_pytest.__file__).dirpath().visit("*.py") diff --git a/tox.ini b/tox.ini index 16984dd43..3e6745dc5 100644 --- a/tox.ini +++ b/tox.ini @@ -171,6 +171,7 @@ filterwarnings = pytester_example_dir = testing/example_scripts markers = issue + slow [flake8] max-line-length = 120