-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
69 lines (44 loc) · 1.48 KB
/
conftest.py
File metadata and controls
69 lines (44 loc) · 1.48 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""
Configuration file for ``pytest``.
This handles
- the command line option to deactivate Numba ``jit``-compilation so that the coverage
tests can be run properly
"""
# === Imports ===
import os
from enum import Enum
# === Models ===
# NOTE: the following code is copied from src/pybandee/_utils/numba_helpers.py
# to avoid an import of the package before the environment variable is set
# an Enum that specifies the possible actions that can be taken regarding Numba
# ``jit``-compilation
class NumbaJitActions(Enum):
"""
Specifies the possible actions that can be taken regarding Numba
``jit``-compilation.
"""
NORMAL = "0"
DEACTIVATE = "1"
# === Constants ===
# the runtime argument that is used to specify that Numba ``jit``-compilation should
# take no effect
NUMBA_NO_JIT_ARGV = "--no-jit"
# the environment variable that is used to specify that Numba ``jit``-compilation should
# take no effect
NUMBA_NO_JIT_ENV_KEY = "CUSTOM_NUMBA_NO_JIT"
# === Functions ===
def pytest_addoption(parser):
"""
Adds the command line option to deactivate Numba ``jit``-compilation.
"""
parser.addoption(
NUMBA_NO_JIT_ARGV,
action="store_true",
help="Disable Numba JIT compilation",
)
def pytest_configure(config):
"""
Configures the runtime environment based on the command line option.
"""
if config.getoption(NUMBA_NO_JIT_ARGV):
os.environ[NUMBA_NO_JIT_ENV_KEY] = NumbaJitActions.DEACTIVATE.value