generated from CuriBio/python-github-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
conftest.py
47 lines (40 loc) · 1.43 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
42
43
44
45
46
47
# -*- coding: utf-8 -*-
"""Pytest configuration."""
import sys
from typing import List
from _pytest.config import Config
from _pytest.config.argparsing import Parser
from _pytest.python import Function
import pytest
sys.dont_write_bytecode = True
sys.stdout = (
sys.stderr
) # allow printing of pytest output when running pytest-xdist https://stackoverflow.com/questions/27006884/pytest-xdist-without-capturing-output
def pytest_addoption(parser: Parser) -> None:
parser.addoption(
"--full-ci",
action="store_true",
default=False,
help="run tests that are marked as only for CI",
)
parser.addoption(
"--include-slow-tests",
action="store_true",
default=False,
help="run tests that are a bit slow",
)
def pytest_collection_modifyitems(config: Config, items: List[Function]) -> None:
if not config.getoption("--full-ci"):
skip_ci_only = pytest.mark.skip(
reason="these tests are skipped unless --full-ci option is set"
)
for item in items:
if "only_run_in_ci" in item.keywords:
item.add_marker(skip_ci_only)
if not config.getoption("--include-slow-tests"):
skip_slow = pytest.mark.skip(
reason="these tests are skipped unless --include-slow-tests option is set"
)
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)