-
Notifications
You must be signed in to change notification settings - Fork 361
Expand file tree
/
Copy pathconftest.py
More file actions
86 lines (70 loc) · 2.03 KB
/
Copy pathconftest.py
File metadata and controls
86 lines (70 loc) · 2.03 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# This file acts as an entry point for pytest.
# Its root directory is added to `sys.path` when pytest is executed
# to fix eventual module import errors that can arise, for example when
# running tests from inside VS code.
# See https://stackoverflow.com/a/34520971
import os
from importlib.metadata import PackageNotFoundError, version
import pytest
from stumpy import rng
def get_specs():
"""
Find and return all package versions
"""
pkgs = [
# Alphabetical Order
"black",
"coverage",
"dask",
"distributed",
"flake8",
"isort",
"numba",
"numpy",
"pandas",
"polars",
"pytest",
"python",
"ray",
"scipy",
]
specs = []
for pkg in pkgs:
try: # pragma: no cover
pkg_version = version(pkg)
specs.append(f"--spec {pkg}={pkg_version}")
except PackageNotFoundError:
pass
return " ".join(specs)
def get_env_vars():
"""
Find and return all environment variables
"""
keys = [
"NUMBA_DISABLE_JIT",
"NUMBA_ENABLE_CUDASIM",
]
env_vars = []
for key in keys:
value = os.getenv(key)
if value is not None:
env_vars.append(f"{key}={value}")
return " ".join(env_vars)
def pytest_configure(config):
"""
Called after command line options have been parsed
and all plugins and initial conftest files been loaded.
"""
# Store details of starting random seed in case of failure
env_vars = get_env_vars()
specs = get_specs()
pytest.STUMPY_MSG = f"\n\nSTUMPY_SEED={rng.SEED} {env_vars} "
pytest.STUMPY_MSG += f"pixi exec {specs} ./test.sh custom 1 {config.args[0]}"
def pytest_sessionfinish(session, exitstatus):
"""
Upon test failure, print additional seed and state
for reproducing test failure
"""
# exitstatus 1 or greater usually indicates failures/errors
if session.testsfailed > 0: # pragma: no cover
print(f"{pytest.STUMPY_MSG}")