-
Notifications
You must be signed in to change notification settings - Fork 9
/
conftest.py
66 lines (55 loc) · 1.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
import pytest
from abra.utils import generate_fake_observations
def pytest_addoption(parser):
parser.addoption(
"--run_stan_tests", action="store_true", default=False,
help="Run Stan tests which are skipped by default. "
"The first time these tests are run requires compiling C++ code, "
"which is cached locally and used afterwards"
)
# https://docs.pytest.org/en/latest/example/simple.html#control-skipping-of-tests-according-to-command-line-option
# https://docs.pytest.org/en/latest/mark.html
def pytest_collection_modifyitems(config, items):
"""
Notes
-----
When adding a new marker, make sure to also register it in the `markers` section of
pytest.ini.
"""
if not config.getoption("--run_stan_tests"):
skip_slow_tests = pytest.mark.skip(
reason="Skipping Stan tests - use --run_stan_tests to run"
)
for item in items:
if "stan_test" in item.keywords:
item.add_marker(skip_slow_tests)
# Put any global fixtures here (https://docs.pytest.org/en/latest/fixture.html)
@pytest.fixture()
def proportions_data_large():
return generate_fake_observations(
distribution='bernoulli',
n_treatments=3,
n_attributes=4,
n_observations=10000
)
@pytest.fixture()
def proportions_data_small():
return generate_fake_observations(
distribution='bernoulli',
n_treatments=6,
n_observations=6 * 50
)
@pytest.fixture()
def means_data():
return generate_fake_observations(
distribution='gaussian',
n_treatments=6,
n_observations=6 * 50
)
@pytest.fixture()
def counts_data():
return generate_fake_observations(
distribution='poisson',
n_treatments=3,
n_observations=3 * 100
)