-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
executable file
·52 lines (39 loc) · 1.32 KB
/
conftest.py
File metadata and controls
executable file
·52 lines (39 loc) · 1.32 KB
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
# conftest.py file to share fixtures between multiple test files
# https://docs.pytest.org/en/latest/fixture.html#conftest-py-sharing-fixture-functions
import numpy as np
import pytest
from data import generate_binary
SEED = 0
np.random.seed(seed=SEED)
# skipping slow tests if --runslow not provided in cli
def pytest_addoption(parser):
parser.addoption(
"--runslow", action="store_true", default=False, help="run slow tests"
)
def pytest_collection_modifyitems(config, items):
if config.getoption("--runslow"):
# --runslow given in cli: do not skip slow tests
return
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)
N_SAMPLES_SMALL = 100
N_FEATURES_SMALL = 20
@pytest.fixture(scope="session")
def dataset():
n_samples = N_SAMPLES_SMALL
n_features = N_FEATURES_SMALL
return generate_binary(n_samples, n_features)
# @pytest.fixture(scope="session")
# def X():
# n_samples = N_SAMPLES_SMALL
# n_features = N_FEATURES_SMALL
# return np.random.rand(n_samples, n_features)
# @pytest.fixture(scope="session")
# def y():
# n_samples = N_SAMPLES_SMALL
# return np.sign(np.random.rand(n_samples, 1))
@pytest.fixture(scope="session")
def lmbd():
return .1