Skip to content

conftest: add uses_pexpect mark #5314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions testing/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a quick description here 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it is rather self-explaining, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, done - also added a new "slowest_items" category.


[flake8]
max-line-length = 120
Expand Down