forked from matplotlib/napari-matplotlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
60 lines (46 loc) · 1.29 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
import os
from pathlib import Path
import numpy as np
import pytest
from skimage import data
@pytest.fixture(
params=[
((100, 100), {"rgb": False}),
((100, 100, 100), {"rgb": False}),
((100, 100, 3), {"rgb": True}),
]
)
def image_data(request):
return np.ones(request.param[0]), request.param[1]
@pytest.fixture
def astronaut_data():
return data.astronaut(), {"rgb": True}
@pytest.fixture
def brain_data():
return data.brain(), {"rgb": False}
@pytest.fixture
def points_with_features_data():
n_points = 100
np.random.seed(10)
points_data = 100 * np.random.random((100, 2))
points_features = {
"feature_0": np.random.random((n_points,)),
"feature_1": np.random.random((n_points,)),
"feature_2": np.random.random((n_points,)),
}
return points_data, {"features": points_features}
@pytest.fixture(autouse=True, scope="session")
def set_strict_qt():
env_var = "NAPARI_STRICT_QT"
old_val = os.environ.get(env_var)
os.environ[env_var] = "1"
# Run tests
yield
# Reset to original value
if old_val is not None:
os.environ[env_var] = old_val
else:
del os.environ[env_var]
@pytest.fixture
def theme_path():
return Path(__file__).parent / "data" / "test_theme.mplstyle"