-
Notifications
You must be signed in to change notification settings - Fork 2
/
conftest.py
54 lines (40 loc) · 1.88 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
"""Project conftest"""
from types import SimpleNamespace # noqa: F401
import pytest
from fixtures.common import * # noqa: F403
from main import features
@pytest.fixture(autouse=True)
def default_settings(monkeypatch, settings): # noqa: PT004
"""Set default settings for all tests"""
monkeypatch.setenv("DJANGO_SETTINGS_MODULE", "main.settings")
settings.FEATURES[features.IGNORE_EDX_FAILURES] = False
settings.FEATURES[features.SYNC_ON_DASHBOARD_LOAD] = False
@pytest.fixture(autouse=True)
def mocked_product_signal(mocker): # noqa: PT004
"""Mock hubspot_sync signals"""
mocker.patch("ecommerce.signals.sync_hubspot_product")
def pytest_addoption(parser):
"""Pytest hook that adds command line parameters"""
parser.addoption(
"--simple",
action="store_true",
help="Run tests only (no cov, warning output silenced)",
)
def pytest_cmdline_main(config):
"""Pytest hook that runs after command line options are parsed"""
if config.option.simple is True:
config.option.pylint = False
config.option.no_pylint = True
def pytest_configure(config):
"""Pytest hook to perform some initial configuration"""
if config.option.simple is True:
# NOTE: These plugins are already configured by the time the pytest_cmdline_main hook is run, so we can't
# simply add/alter the command line options in that hook. This hook is being used to
# reconfigure/unregister plugins that we can't change via the pytest_cmdline_main hook.
# Switch off coverage plugin
cov = config.pluginmanager.get_plugin("_cov")
cov.options.no_cov = True
# Remove warnings plugin to suppress warnings
if config.pluginmanager.has_plugin("warnings"):
warnings_plugin = config.pluginmanager.get_plugin("warnings")
config.pluginmanager.unregister(warnings_plugin)