forked from ScipioWright/Archipelago-SW
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
31 lines (25 loc) · 1.14 KB
/
Copy pathconftest.py
File metadata and controls
31 lines (25 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
def pytest_configure(config):
# AP_TEST_WORLDS implies `-m world` unless an explicit -m was given; the scoping itself lives in
# worlds/__init__
if os.environ.get("AP_TEST_WORLDS") and not config.option.markexpr:
config.option.markexpr = "world"
def pytest_ignore_collect(collection_path, config):
# skip worlds/<world>/... for any world not named, so other worlds are never imported
env = os.environ.get("AP_TEST_WORLDS")
if not env:
return None
selected = {name.strip() for name in env.split(",") if name.strip()}
parts = collection_path.parts
if "worlds" in parts:
i = parts.index("worlds")
if i + 1 < len(parts) and parts[i + 1] not in selected:
return True
return None
def pytest_collection_modifyitems(items):
# mark for `-m world`: classes with `world_relevant = True`, plus anything under worlds/ (nodeid is
# always "/"-separated and relative to rootdir)
for item in items:
if getattr(getattr(item, "cls", None), "world_relevant", False) or \
item.nodeid.split("/", 1)[0] == "worlds":
item.add_marker("world")