Sort conftest modules before importing
Sort conftest modules before importing
ISSUE:
([arc::pullid] b55d491-22f7559c-64882a4c-66b158b5)
@@ -18,8 +18,15 @@ conftest_modules = []
def pytest_addhooks(pluginmanager):
- for name in sys.extra_modules:
- if name.endswith('.conftest'):
+ conftests = filter(lambda name: name.endswith(".conftest"), sys.extra_modules)
+
+ def conftest_key(name):
+ if not name.startswith("__tests__."):
+ # Make __tests__ come last
+ return "_." + name
+ return name
+
+ for name in sorted(conftests, key=conftest_key):
mod = importlib.import_module(name)
mod.__orig_file__ = mod.__file__
mod.__file__ = ''
