forked from CSS-Electronics/can_decoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
47 lines (35 loc) · 1.09 KB
/
conftest.py
File metadata and controls
47 lines (35 loc) · 1.09 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
import os
import pytest
def pytest_addoption(parser):
parser.addoption(
"-E",
action="store",
metavar="NAME",
help="only run tests matching the environment NAME.",
)
parser.addoption(
"--with-tox",
default=False,
action="store_true"
)
return
def pytest_configure(config):
# register an additional marker
config.addinivalue_line(
"markers", "env(name): mark test to run only on named environment"
)
def pytest_runtest_setup(item: pytest.Function):
config = item.config
with_tox = config.getoption("--with-tox")
if not with_tox:
return
envnames = [mark.args[0] for mark in item.iter_markers(name="env")]
optional = os.environ.get("OPTIONAL_PACKAGES_AVAILABLE")
if envnames:
if not optional:
pytest.skip("test requires env in {!r}".format(envnames))
return
for env in envnames:
if env not in optional:
pytest.skip("test requires env in {!r}".format(envnames))
return