-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
58 lines (46 loc) · 1.72 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
48
49
50
51
52
53
54
55
56
57
58
"""Pytest configurations
"""
from typing import TYPE_CHECKING
import pytest
import logging
import chromedriver_binary # noqa: F401
def pytest_addoption(parser):
parser.addoption(
"--with-dash",
action="store_true",
help=(
"Run the optional tests for local dash app. They require Chrome driver "
"supports."
),
)
def pytest_configure(config):
logging.getLogger("werkzeug").setLevel(logging.ERROR)
config.addinivalue_line(
"markers", "with_dash: run the dash test with Chrome driver."
)
def pytest_collection_modifyitems(config, items):
if config.getoption("--with-dash"):
# --runslow given in cli: do not skip slow tests
return
skip_wdash = pytest.mark.skip(reason="need --with-dash option to run")
for item in items:
if "with_dash" in item.keywords:
item.add_marker(skip_wdash)
if not TYPE_CHECKING:
try:
from selenium.webdriver.chrome.options import Options
def pytest_setup_options():
# raise TypeError(same_hook)
# The following configuration requires the installation of chrome!
options = Options()
# Removes a bunch of errors on Windows, like
# USB: usb_device_win.cc:93 Failed to read descriptors from ...
options.add_experimental_option("excludeSwitches", ["enable-logging"])
# Do not need to configure --headless because it is included in the
# pytest option (provided by dash_duo).
# options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-gpu")
return options
except ImportError:
pass