-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
26 lines (22 loc) · 891 Bytes
/
conftest.py
File metadata and controls
26 lines (22 loc) · 891 Bytes
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
# conftest.py
from pathlib import Path
import pytest
ROOT_SENTINELS = ("pyproject.toml", "setup.cfg", "setup.py", ".git")
def _find_project_root(start: Path) -> Path:
# Walk up until we find a typical project root sentinel; fallback to start
for p in [start, *start.parents]:
if any((p / s).exists() for s in ROOT_SENTINELS):
return p
return start
def _big_tests_exists() -> bool:
here = Path(__file__).resolve()
root = _find_project_root(here)
return (root / "big_tests").is_dir()
def pytest_collection_modifyitems(config, items):
# If no big_tests/ directory, skip anything marked big_test
if _big_tests_exists():
return
skip_marker = pytest.mark.skip(reason="Skipped because project has no 'big_tests/' directory.")
for item in items:
if "big_test" in item.keywords:
item.add_marker(skip_marker)