-
Notifications
You must be signed in to change notification settings - Fork 154
Expand file tree
/
Copy pathconftest.py
More file actions
28 lines (22 loc) · 875 Bytes
/
conftest.py
File metadata and controls
28 lines (22 loc) · 875 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
27
28
from __future__ import annotations
import os
import sys
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent
def pytest_configure() -> None:
os.environ.setdefault("MPLBACKEND", "Agg")
os.environ.setdefault("MPLCONFIGDIR", "/tmp/matplotlib")
os.environ.setdefault("XDG_CACHE_HOME", "/tmp")
Path("/tmp/matplotlib").mkdir(parents=True, exist_ok=True)
if str(REPO_ROOT) not in sys.path:
sys.path.insert(0, str(REPO_ROOT))
if str(REPO_ROOT / "book") not in sys.path:
sys.path.insert(0, str(REPO_ROOT / "book"))
def pytest_ignore_collect(collection_path, config): # type: ignore[no-untyped-def]
solutions_dir = REPO_ROOT / "solutions"
if solutions_dir.exists():
return None
try:
return Path(collection_path).resolve().is_relative_to(solutions_dir)
except Exception:
return None