-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconftest.py
41 lines (29 loc) · 883 Bytes
/
conftest.py
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
import sys
from pathlib import Path
from warnings import warn
import pytest
BASE_DIR = Path(__file__).parent
def iter_parents(path: Path):
if path.is_dir():
yield path
while path != path.root:
path = path.parent
yield path
path = Path.cwd()
for path in iter_parents(Path.cwd()):
if (path / "supermat").is_dir():
str_path = str(path)
if str_path not in sys.path:
sys.path.insert(0, str_path)
break
else:
warn("Could not find a parent directory which contained the supermat module.")
@pytest.fixture(scope="session")
def test_json() -> Path:
return BASE_DIR / "test_samples/test.json"
@pytest.fixture(scope="session")
def test_pdf() -> Path:
return BASE_DIR / "test_samples/test.pdf"
@pytest.fixture(scope="session")
def test_docx() -> Path:
return BASE_DIR / "test_samples/test.docx"