Debian Codegraph @

conftest.py

raw
1 import sys
2 import os
3 import json
4 import pytest
5
6 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'tests')))
7
8 FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'tests/fixtures/')
9
10
11 def pytest_addoption(parser):
12 parser.addoption(
13 "--runslow", action="store_true", default=False, help="run slow tests"
14 )
15
16
17 def pytest_configure(config):
18 config.addinivalue_line("markers", "slow: mark test as slow to run")
19
20
21 def pytest_collection_modifyitems(config, items):
22 if config.getoption("--runslow"):
23 # --runslow given in cli: do not skip slow tests
24 return
25 skip_slow = pytest.mark.skip(reason="need --runslow option to run")
26 for item in items:
27 if "slow" in item.keywords:
28 item.add_marker(skip_slow)
29
30
31 @pytest.fixture(scope='class')
32 def nested_a_t1():
33 with open(os.path.join(FIXTURES_DIR, 'nested_a_t1.json')) as the_file:
34 return json.load(the_file)
35
36
37 @pytest.fixture(scope='class')
38 def nested_a_t2():
39 with open(os.path.join(FIXTURES_DIR, 'nested_a_t2.json')) as the_file:
40 return json.load(the_file)
41
42
43 @pytest.fixture(scope='class')
44 def nested_a_result():
45 with open(os.path.join(FIXTURES_DIR, 'nested_a_result.json')) as the_file:
46 return json.load(the_file)
47
48
49 @pytest.fixture(scope='function')
50 def compounds():
51 with open(os.path.join(FIXTURES_DIR, 'compounds.json')) as the_file:
52 return json.load(the_file)
53
54
55 @pytest.fixture(scope='class')
56 def nested_a_affected_paths():
57 return {
58 'root[0][0][2][0][1]', 'root[0][1][1][1][5]', 'root[0][2][1]',
59 'root[1][1][2][0][1]', 'root[1][2][0]', 'root[1][2][0][1][5]',
60 'root[1][0][2][2][3]', 'root[0][0][1][0][0]', 'root[0][1][0][2][3]',
61 'root[0][3][0][2][3]', 'root[0][3][1][0][2]', 'root[1][1][1][0][0]',
62 'root[1][0][1][2][1]', 'root[1][0][2][1][2]', 'root[1][3][0][2][3]',
63 'root[1][3][1][0][2]', 'root[1][2][0][2]', 'root[1][0][2][0][1]',
64 'root[0][3][2][0][1]', 'root[0][3][2][1][0]', 'root[1][3][1][1]',
65 'root[1][2][1][1][0]', 'root[1][2][1][0]', 'root[1][0][0][0][2]',
66 'root[1][3][2][1][0]', 'root[1][0][0][1][1]', 'root[0][1][2][0]',
67 'root[0][1][2][1][0]', 'root[0][2][0][1][2]', 'root[1][3][0][1]',
68 'root[0][3][1][1]', 'root[1][2][0][0][2]', 'root[1][3][2][0][1]',
69 'root[1][0][1][0]', 'root[1][2][0][0][0]', 'root[1][0][0][0][1]',
70 'root[1][3][2][2][2]', 'root[0][1][1][2][1]', 'root[0][1][1][2][2]',
71 'root[0][2][0][0][2]', 'root[0][2][0][0][3]', 'root[0][3][1][2][1]',
72 'root[0][3][1][2][2]', 'root[1][2][1][2][3]', 'root[1][0][0][1][2]',
73 'root[1][0][0][2][1]', 'root[1][3][1][2][1]', 'root[1][3][1][2][2]'
74 }
75
76
77 @pytest.fixture(scope='class')
78 def nested_b_t1():
79 with open(os.path.join(FIXTURES_DIR, 'nested_b_t1.json')) as the_file:
80 return json.load(the_file)
81
82
83 @pytest.fixture(scope='class')
84 def nested_b_t2():
85 with open(os.path.join(FIXTURES_DIR, 'nested_b_t2.json')) as the_file:
86 return json.load(the_file)
87
88
89 @pytest.fixture(scope='class')
90 def nested_b_result():
91 with open(os.path.join(FIXTURES_DIR, 'nested_b_result.json')) as the_file:
92 return json.load(the_file)
93
94
95 @pytest.fixture(scope='class')
96 def compare_func_t1():
97 with open(os.path.join(FIXTURES_DIR, 'compare_func_t1.json')) as the_file:
98 return json.load(the_file)
99
100
101 @pytest.fixture(scope='class')
102 def compare_func_t2():
103 with open(os.path.join(FIXTURES_DIR, 'compare_func_t2.json')) as the_file:
104 return json.load(the_file)
105
106
107 @pytest.fixture(scope='class')
108 def compare_func_result1():
109 with open(os.path.join(FIXTURES_DIR, 'compare_func_result1.json')) as the_file:
110 return json.load(the_file)