Prefer faster tests. Use a hookwrapper to do this in the beginning, so e.g. --ff still works correctly.
(items)
| 22 | |
| 23 | @pytest.hookimpl(hookwrapper=True, tryfirst=True) |
| 24 | def pytest_collection_modifyitems(items): |
| 25 | """Prefer faster tests. |
| 26 | |
| 27 | Use a hookwrapper to do this in the beginning, so e.g. --ff still works |
| 28 | correctly. |
| 29 | """ |
| 30 | fast_items = [] |
| 31 | slow_items = [] |
| 32 | slowest_items = [] |
| 33 | neutral_items = [] |
| 34 | |
| 35 | spawn_names = {"spawn_pytest", "spawn"} |
| 36 | |
| 37 | for item in items: |
| 38 | try: |
| 39 | fixtures = item.fixturenames |
| 40 | except AttributeError: |
| 41 | # doctest at least |
| 42 | # (https://github.com/pytest-dev/pytest/issues/5070) |
| 43 | neutral_items.append(item) |
| 44 | else: |
| 45 | if "pytester" in fixtures: |
| 46 | co_names = item.function.__code__.co_names |
| 47 | if spawn_names.intersection(co_names): |
| 48 | item.add_marker(pytest.mark.uses_pexpect) |
| 49 | slowest_items.append(item) |
| 50 | elif "runpytest_subprocess" in co_names: |
| 51 | slowest_items.append(item) |
| 52 | else: |
| 53 | slow_items.append(item) |
| 54 | item.add_marker(pytest.mark.slow) |
| 55 | else: |
| 56 | marker = item.get_closest_marker("slow") |
| 57 | if marker: |
| 58 | slowest_items.append(item) |
| 59 | else: |
| 60 | fast_items.append(item) |
| 61 | |
| 62 | items[:] = fast_items + neutral_items + slow_items + slowest_items |
| 63 | |
| 64 | yield |
| 65 | |
| 66 | |
| 67 | @pytest.fixture |
nothing calls this directly
no test coverage detected