-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconftest.py
More file actions
46 lines (34 loc) · 1.14 KB
/
conftest.py
File metadata and controls
46 lines (34 loc) · 1.14 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
import pytest
from .configs import RUN_SLOW_TESTS
RUN_SLOW_ARG_NAME = "run_slow"
@pytest.hookimpl()
def pytest_sessionstart(session):
pass
# @pytest.hookimpl()
# def pytest_sessionfinish(session, exitstatus):
# reporter = session.config.pluginmanager.get_plugin('terminalreporter')
# print('passed amount:', len(reporter.stats['passed']))
def pytest_addoption(parser):
r"""
Add options to the pytest command.
See: https://jwodder.github.io/kbits/posts/pytest-mark-off/.
:param parser: The pytest parser.
:return: None
"""
parser.addoption(
f"--{RUN_SLOW_ARG_NAME}",
action="store_true",
default=RUN_SLOW_TESTS,
help="Run slow tests",
)
def pytest_collection_modifyitems(config, items):
if config.getoption(f"--{RUN_SLOW_ARG_NAME}"):
# if RUN_SLOW_TESTS:
# print("Running slow tests")
pass
else:
# print("Skipping slow tests")
skipper = pytest.mark.skip(reason=f"Only run when '--{RUN_SLOW_ARG_NAME}=True' is given")
for item in items:
if "slow" in item.keywords:
item.add_marker(skipper)