-
Notifications
You must be signed in to change notification settings - Fork 14
/
conftest.py
45 lines (36 loc) · 1.7 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
# content of conftest.py
import logging
import pytest
def pytest_addoption(parser):
parser.addoption(
"--runcloud", action="store_true", default=False, help="run cloud tests"
)
parser.addoption(
"--runslow", action="store_true", default=False, help="run slow tests"
)
def pytest_configure(config):
config.addinivalue_line("markers", "cloud: mark test as needing cloud to run")
config.addinivalue_line("markers", "slow: mark test as slow to run")
def pytest_collection_modifyitems(config, items):
if not config.getoption("--runcloud"):
# --runcloud not given in cli: skip cloud tests
skip_cloud = pytest.mark.skip(reason="need --runcloud option to run")
for item in items:
if "cloud" in item.keywords:
item.add_marker(skip_cloud)
if not config.getoption("--runslow"):
# --runslow not given in cli: skip slow tests
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)
# from https://github.com/streamlit/streamlit/pull/5047/files
def pytest_sessionfinish():
# We're not waiting for scriptrunner threads to cleanly close before ending the PyTest,
# which results in raised exception ValueError: I/O operation on closed file.
# This is well known issue in PyTest, check out these discussions for more:
# * https://github.com/pytest-dev/pytest/issues/5502
# * https://github.com/pytest-dev/pytest/issues/5282
# To prevent the exception from being raised on pytest_sessionfinish
# we disable exception raising in logging module
logging.raiseExceptions = False