Alexander Hess
7e3e67c300
- extend `pytest` with an option to run only the minimum number of (unit) test cases to just keep the coverage at 100% - rationale: + many of the unit test cases partly overlap with respect to the lines of source code executed + also, integration tests, by definition, do not contribute to a higher test coverage - implementation: mark "redundant" test cases as one of: + `pytest.mark.integration_test` => code usage from the perspective of the end user + `pytest.mark.overlapping_test` => tests not contributing to the 100% coverage + `pytest.mark.sanity_test` => tests providing confidence in the test data - add `tests.conftest` module => programatically convert the above markers into `@pytest.mark.no_cover` and collect the non-"redundant" tests - add nox session "test-fast" to run only the minimum number of (unit) test while holding coverage at 100% - refactor some test modules + wrap some test cases in a class + move sanity tests to the end of the files
32 lines
801 B
Python
32 lines
801 B
Python
"""Integrate `xdoctest` into the test suite.
|
|
|
|
Ensure all code snippets in docstrings are valid and functioning code.
|
|
|
|
Important: All modules with docstrings containing code snippets
|
|
must be put on the parameter list below by hand!
|
|
"""
|
|
|
|
import pytest
|
|
import xdoctest
|
|
|
|
|
|
@pytest.mark.integration_test
|
|
@pytest.mark.parametrize(
|
|
"module",
|
|
[
|
|
"lalib",
|
|
"lalib.elements",
|
|
"lalib.elements.galois",
|
|
"lalib.fields",
|
|
"lalib.fields.base",
|
|
"lalib.fields.complex_",
|
|
"lalib.fields.galois",
|
|
"lalib.fields.rational",
|
|
"lalib.fields.real",
|
|
],
|
|
)
|
|
def test_docstrings(module):
|
|
"""Test code snippets within the package with `xdoctest`."""
|
|
result = xdoctest.doctest_module(module, "all")
|
|
|
|
assert result["n_failed"] == 0
|