Commit 5ee16013 authored by hynek's avatar hynek 🤤
Browse files

test: reconfigure pytest and coverage

skip empty, init, admins, apps
parent 0c2418e5
[run]
include = discuss_data/*
omit = *migrations*, *tests*
omit = venv/*, */tests/*, */migrations/*, */urls.py, */settings/*
plugins =
django_coverage_plugin
[report]
skip_empty = True
omit = */__init__.py, */admin.py, */apps.py
[html]
directory = htmlcov
__version__ = "0.5.0"
__version_info__ = tuple(
[
int(num) if num.isdigit() else num
for num in __version__.replace("-", ".", 1).split(".")
]
)
import pytest
# enable database for all tests
@pytest.fixture(autouse=True)
def enable_db_access_for_all_tests(db):
pass
# pytest finds added options only in root conftest.py if not configured otherwise
def pytest_addoption(parser):
......@@ -14,3 +19,13 @@ def pytest_addoption(parser):
# list marker if requested with 'pytest --markers'
def pytest_configure(config):
config.addinivalue_line("markers", "integration: mark a test as integration test")
def pytest_collection_modifyitems(config, items):
if config.getoption("--integration"):
# --integration given in cli: do not skip integration tests
return
skip_integration = pytest.mark.skip(reason="need --integration option to run")
for item in items:
if "integration" in item.keywords:
item.add_marker(skip_integration)
from django.test import TestCase
# Create your tests here.
from django.test import TestCase
# Create your tests here.
from django.test import TestCase
# Create your tests here.
[pytest]
addopts = --ds=config.settings.test
DJANGO_SETTINGS_MODULE = config.settings.test
python_files = tests.py test_*.py
norecursedirs = node_modules
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment