From 0025e4408f51b9d1eecd36a4692e61721c883cc4 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 27 May 2019 03:20:58 +0200 Subject: [PATCH] conftest: add uses_pexpect mark --- testing/conftest.py | 13 +++++++++---- tox.ini | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/testing/conftest.py b/testing/conftest.py index ecc945279..a068550e8 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -11,9 +11,10 @@ def pytest_collection_modifyitems(config, items): """ fast_items = [] slow_items = [] + slowest_items = [] neutral_items = [] - slow_fixturenames = ("testdir",) + spawn_names = {"spawn_pytest", "spawn"} for item in items: try: @@ -23,12 +24,16 @@ def pytest_collection_modifyitems(config, items): # (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) + if "testdir" in fixtures: + if spawn_names.intersection(item.function.__code__.co_names): + item.add_marker(pytest.mark.uses_pexpect) + slow_items.append(item) + else: + slowest_items.append(0) else: marker = item.get_closest_marker("slow") if marker: - slow_items.append(item) + slowest_items.append(item) else: fast_items.append(item) diff --git a/tox.ini b/tox.ini index 1f024b2f5..a04f91ae5 100644 --- a/tox.ini +++ b/tox.ini @@ -175,6 +175,8 @@ markers = baz # conftest.py reorders tests moving slow ones to the end of the list slow + # experimental mark for all tests using pexpect + uses_pexpect [flake8] max-line-length = 120