-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathconftest.py
More file actions
77 lines (56 loc) · 2.03 KB
/
Copy pathconftest.py
File metadata and controls
77 lines (56 loc) · 2.03 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""Shared pytest fixtures for odp.
These paths replace the ad-hoc sys.path.insert dance in test files. Any
test that needs to import a module from `source/`, `scripts/`, or
`dependencies/afp.py` should depend on the matching fixture (which
also prepends to sys.path the first time it is resolved).
"""
from __future__ import annotations
import sys
from pathlib import Path
import pytest
@pytest.fixture(scope="session")
def repo_root() -> Path:
return Path(__file__).resolve().parent
@pytest.fixture(scope="session")
def source_dir(repo_root: Path) -> Path:
path = repo_root / "source"
sys.path.insert(0, str(path))
return path
@pytest.fixture(scope="session")
def scripts_dir(repo_root: Path) -> Path:
path = repo_root / "scripts"
sys.path.insert(0, str(path))
return path
@pytest.fixture(scope="session")
def fasta_parser_dir(repo_root: Path) -> Path:
"""Path to the vendored fastx parser. Inserts the parser's parent
directory onto sys.path so that ``import afp`` (or
``import afp as fasta`` in legacy callsites) resolves to
``dependencies/afp.py``."""
deps = repo_root / "dependencies"
sys.path.insert(0, str(deps))
return deps / "afp.py"
@pytest.fixture(scope="session")
def tests_dir(repo_root: Path) -> Path:
return repo_root / "tests"
@pytest.fixture(scope="session")
def testdb_dir(tests_dir: Path) -> Path:
return tests_dir / "testdb"
@pytest.fixture(scope="session")
def mini_hydra(testdb_dir: Path) -> Path:
path = testdb_dir / "mini_hydra"
if not path.is_dir():
pytest.skip(f"mini_hydra fixture missing at {path}")
return path
@pytest.fixture(scope="session")
def mini_urchin(testdb_dir: Path) -> Path:
path = testdb_dir / "mini_urchin"
if not path.is_dir():
pytest.skip(f"mini_urchin fixture missing at {path}")
return path
@pytest.fixture(scope="session")
def mini_lg_db(testdb_dir: Path) -> Path:
path = testdb_dir / "mini_LG_db"
if not path.is_dir():
pytest.skip(f"mini_LG_db fixture missing at {path}")
return path