Merge pull request #5071 from blueyed/prefer-fast

Add a conftest to prefer faster tests
This commit is contained in:
Daniel Hahler 2019-04-10 01:22:24 +02:00 committed by GitHub
commit fcbfdef11b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 0 deletions

26
testing/conftest.py Normal file
View File

@ -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

View File

@ -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")

View File

@ -171,6 +171,7 @@ filterwarnings =
pytester_example_dir = testing/example_scripts
markers =
issue
slow
[flake8]
max-line-length = 120