forked from sio2project/oioioi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
52 lines (37 loc) · 1.7 KB
/
conftest.py
File metadata and controls
52 lines (37 loc) · 1.7 KB
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
import pytest
from django.conf import settings
from oioioi.base.tests import pytest_plugin as base_plugin
from oioioi.contests.tests import pytest_plugin as contests_plugin
def pytest_addoption(parser):
parser.addoption("--runslow", action="store_true", default=False, help="run slow tests")
parser.addoption("--strict-template-vars", action="store_true", help="Raise errors for undefined template variables")
# called for running each test
def pytest_runtest_setup(item):
contests_plugin.pytest_runtest_setup(item)
base_plugin.pytest_runtest_setup(item)
def pytest_configure(config):
if config.getoption("--strict-template-vars"):
# this will raise an error if a template variable is not defined
settings.TEMPLATES[0]["OPTIONS"]["string_if_invalid"] = "{% templatetag openvariable %} INVALID_VAR: %s {% templatetag closevariable %}"
def pytest_collection_modifyitems(config, items):
# --runslow flag: do not skip slow tests
if config.getoption("--runslow", False):
return
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)
# Removing links column from html report
@pytest.hookimpl(optionalhook=True)
def pytest_html_results_table_header(cells):
cells.pop()
# Removing links column from html report
@pytest.hookimpl(optionalhook=True)
def pytest_html_results_table_row(report, cells):
cells.pop()
@pytest.fixture()
def require_migrations_flag(request):
config = request.config
nomigrations_enabled_flag = config.getoption("nomigrations")
if nomigrations_enabled_flag:
pytest.skip("Test requires the --migrations flag to run.")