-
Notifications
You must be signed in to change notification settings - Fork 3
/
conftest.py
94 lines (72 loc) · 1.89 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
"""
Global test configuration. Use this file to define fixtures to use
in both doctests and regular tests.
"""
import pytest
import numpy as np
@pytest.fixture
def points():
return np.array([
(0, 0),
(0, 1),
(1, 0),
(1, 1),
(0, -1),
(-1, 0),
(-1, -1)
])
@pytest.fixture
def indices():
return np.array([
(0, 0),
(1, 0),
(0, 1),
(1, 1),
(-1, 0),
(0, -1),
(-1, -1)
])
@pytest.fixture
def zero():
return np.array([0, 0])
@pytest.fixture
def a():
return np.array([0, 1])
@pytest.fixture
def b():
return np.array([1, 0])
@pytest.fixture(autouse=True)
def auto_ctx(doctest_namespace):
try:
from libertem.executor.inline import InlineJobExecutor
from libertem import api as lt
ctx = lt.Context(executor=InlineJobExecutor())
except ImportError:
ctx = None
doctest_namespace["ctx"] = ctx
@pytest.fixture(autouse=True)
def auto_ds(doctest_namespace):
try:
from libertem.io.dataset.memory import MemoryDataSet
dataset = MemoryDataSet(datashape=[16, 16, 16, 16])
except ImportError:
dataset = None
doctest_namespace["dataset"] = dataset
@pytest.fixture(autouse=True)
def auto_libs(doctest_namespace):
doctest_namespace["np"] = np
@pytest.fixture(autouse=True)
def auto_blobfinder(doctest_namespace):
import libertem_blobfinder
doctest_namespace["libertem_blobfinder"] = libertem_blobfinder
@pytest.fixture(autouse=True)
def auto_libertem(doctest_namespace):
try:
import libertem
import libertem.api
import libertem_blobfinder
doctest_namespace["libertem"] = libertem
doctest_namespace["libertem.api"] = libertem.api
doctest_namespace["libertem_blobfinder"] = libertem_blobfinder
except ImportError:
pass # anything better to do here?