-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconftest.py
41 lines (30 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
39
40
41
from os import environ
from platform import system
import pytest
def is_in_ci():
# if running in GitHub Actions CI, "CI" variable always set to true
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
return bool(environ.get("CI", None))
def requires_platform(platform, ci_only=False):
return pytest.mark.skipif(
system().lower() != platform.lower() and (is_in_ci() if ci_only else True),
reason=f"only compatible with platform: {platform.lower()}",
)
def excludes_platform(platform, ci_only=False):
return pytest.mark.skipif(
system().lower() == platform.lower() and (is_in_ci() if ci_only else True),
reason=f"not compatible with platform: {platform.lower()}",
)
def pytest_addoption(parser):
parser.addoption(
"-S",
"--smoke",
action="store_true",
default=False,
help="Run only smoke tests (should complete in <1 minute)."
)
def pytest_runtest_setup(item):
smoke = item.config.getoption("--smoke")
slow = list(item.iter_markers(name="slow"))
if smoke and slow:
pytest.skip()