-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathconftest.py
38 lines (29 loc) · 1.15 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
"""Main configuration file for pytest."""
import shutil
from tsml_eval.experiments import experiments
from tsml_eval.testing.testing_utils import _TEST_OUTPUT_PATH
KEEP_PYTEST_OUTPUT = False
def pytest_sessionfinish(session, exitstatus):
"""Call after test run is finished, before returning the exit status to system."""
if not hasattr(session.config, "workerinput") and not KEEP_PYTEST_OUTPUT:
shutil.rmtree(_TEST_OUTPUT_PATH, ignore_errors=True)
def pytest_addoption(parser):
"""Pytest command line parser options adder."""
parser.addoption(
"--meminterval",
type=float,
default=5.0,
help="Set the time interval in seconds for recording memory usage "
"(default: %(default)s).",
)
parser.addoption(
"--keepoutput",
action="store_true",
help="Keep the unit test output folder after running pytest"
" (default: %(default)s).",
)
def pytest_configure(config):
"""Pytest configuration preamble."""
experiments.MEMRECORD_INTERVAL = config.getoption("--meminterval")
global KEEP_PYTEST_OUTPUT
KEEP_PYTEST_OUTPUT = config.getoption("--keepoutput")