Skip to content

Commit

Permalink
Run tests in randome order (#1799)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbernat authored May 1, 2020
1 parent 18de796 commit bb7bb71
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ testing =
pytest-xdist >= 1.31.0
pytest-mock >= 2
pytest-env >= 0.6.2
pytest-randomly >= 1
xonsh >= 0.9.16; python_version > '3.4'

[options.package_data]
Expand Down
13 changes: 13 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ def pytest_addoption(parser):
parser.addoption("--int", action="store_true", default=False, help="run integration tests")


def pytest_configure(config):
"""Ensure randomly is called before we re-order"""
manager = config.pluginmanager
# noinspection PyProtectedMember
order = manager.hook.pytest_collection_modifyitems._nonwrappers
dest = next((i for i, p in enumerate(order) if p.plugin is manager.getplugin("randomly")), None)
if dest is not None:
from_pos = next(i for i, p in enumerate(order) if p.plugin is manager.getplugin(__file__))
temp = order[dest]
order[dest] = order[from_pos]
order[from_pos] = temp


def pytest_collection_modifyitems(config, items):
int_location = os.path.join("tests", "integration", "").rstrip()
if len(items) == 1:
Expand Down

0 comments on commit bb7bb71

Please sign in to comment.