-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
38 lines (26 loc) · 1.03 KB
/
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
import typing as t
import pytest
pytest.register_assert_rewrite("atomlib.atoms", "atomlib.atomcell", "atomlib.testing")
if t.TYPE_CHECKING:
from atomlib import HasAtoms
@pytest.fixture(scope='function')
def expected_structure(request) -> 'HasAtoms':
from atomlib.io import read
from atomlib.testing import OUTPUT_PATH
marker = request.node.get_closest_marker('expected_filename')
name = str(marker.args[0])
return read(OUTPUT_PATH / name)
@pytest.fixture(scope='function')
def expected_contents_text(request) -> str:
from atomlib.testing import OUTPUT_PATH
marker = request.node.get_closest_marker('expected_filename')
name = str(marker.args[0])
with open(OUTPUT_PATH / name, 'r') as f:
return f.read()
@pytest.fixture(scope='function')
def expected_contents_binary(request) -> bytes:
from atomlib.testing import OUTPUT_PATH
marker = request.node.get_closest_marker('expected_filename')
name = str(marker.args[0])
with open(OUTPUT_PATH / name, 'rb') as f:
return f.read()