-
Notifications
You must be signed in to change notification settings - Fork 151
/
conftest.py
75 lines (56 loc) · 2.79 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
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
import os
import matplotlib
matplotlib.use('agg')
import pytest # noqa: E402
from allensdk.test_utilities.temp_dir import temp_dir # noqa: E402
@pytest.fixture(scope="function")
def fn_temp_dir(request):
return temp_dir(request)
@pytest.fixture(scope="module")
def md_temp_dir(request):
return temp_dir(request)
def pytest_collection_modifyitems(config, items):
''' A pytest magic function. This function is called post-collection and gives us a hook for modifying the
collected items.
'''
skip_api_endpoint_test = pytest.mark.skipif(
'TEST_API_ENDPOINT' not in os.environ,
reason='this test requires that an API endpoint be specified (set the TEST_API_ENDPOINT environment variable).'
)
skip_nightly_test = pytest.mark.skipif(
os.getenv('TEST_COMPLETE') != 'true',
reason='this test is either time/memory/compute expensive or it depends on resources internal to the Allen Institute. '\
'Either way, it does\'nt run by default and must be opted into (it does run in our nightly builds).'
)
skip_flaky_test = pytest.mark.skipif(
(os.getenv('TEST_COMPLETE') != 'true') and (os.getenv('TEST_FLAKY') != 'true'),
reason='this test does not consistently pass (for instance, because it makes requests that sometimes time out).'\
'All such tests should be fixed, but in the mean time we\'ve restricted it to run in our nightly build only '\
'in order to reduce the prevalence of bogus test results.'
)
skip_prerelease_test = pytest.mark.skipif(
os.environ.get('TEST_PRERELEASE') != 'true',
reason='prerelease tests are only valid if external and internal data expected to align'
)
skip_neuron_test = pytest.mark.skipif(
os.getenv('TEST_NEURON') != 'true',
reason='this test depends on the NEURON simulation library. This dependency is not straghtforward to build '\
'and install, so you must opt in to running this test'
)
skip_outside_bamboo_test = pytest.mark.skipif(
os.environ.get('TEST_BAMBOO') != 'true',
reason='this test depends on the resources only available to Bamboo agents, but are still fast. If they are slow, mark with nightly'
)
for item in items:
if 'requires_api_endpoint' in item.keywords:
item.add_marker(skip_api_endpoint_test)
if 'nightly' in item.keywords:
item.add_marker(skip_nightly_test)
if 'todo_flaky' in item.keywords:
item.add_marker(skip_flaky_test)
if 'prerelease' in item.keywords:
item.add_marker(skip_prerelease_test)
if 'requires_neuron' in item.keywords:
item.add_marker(skip_neuron_test)
if 'requires_bamboo' in item.keywords:
item.add_marker(skip_outside_bamboo_test)