Merge pull request #5071 from blueyed/prefer-fast
Add a conftest to prefer faster tests
This commit is contained in:
commit
fcbfdef11b
|
@ -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
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue