2024-09-10 01:57:02 +02:00
|
|
|
"""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
|
|
|
|
|
|
|
|
|
2024-10-15 01:49:32 +02:00
|
|
|
@pytest.mark.integration_test
|
2024-09-10 01:57:02 +02:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"module",
|
|
|
|
[
|
|
|
|
"lalib",
|
2024-10-20 02:35:43 +02:00
|
|
|
"lalib.domains",
|
2024-09-18 18:29:40 +02:00
|
|
|
"lalib.elements",
|
2024-09-19 12:14:20 +02:00
|
|
|
"lalib.elements.galois",
|
Add `Q`, `R`, `C`, and `GF2` fields
- add `lalib.fields.base.Field`, a blueprint for all concrete fields,
providing a unified interface to be used outside of the
`lalib.fields` sub-package
- implement `lalib.fields.complex_.ComplexField`, or `C` for short,
the field over the complex numbers (modeled as `complex` numbers)
- implement `lalib.fields.galois.GaloisField2`, or `GF2` for short,
the (finite) field over the two elements `one` and `zero`
+ adapt `lalib.elements.galois.GF2Element.__eq__()` to return
`NotImplemented` instead of `False` for non-castable `other`s
=> this fixes a minor issue with `pytest.approx()`
- implement `lalib.fields.rational.RationalField`, or `Q` for short,
the field over the rational numbers (modeled as `fractions.Fraction`s)
- implement `lalib.fields.real.RealField`, or `R` for short,
the field over the real numbers (modeled as `float`s)
- organize top-level imports for `lalib.fields`,
making `Q`, `R`, `C`, and `GF2` importable with
`from lalib.fields import *`
- provide extensive unit and integration tests for the new objects:
+ test generic and common behavior in `tests.fields.test_base`
+ test specific behavior is other modules
+ test the well-known math axioms for all fields (integration tests)
+ test the new objects' docstrings
+ add "pytest-repeat" to run randomized tests many times
2024-10-14 15:17:42 +02:00
|
|
|
"lalib.fields",
|
|
|
|
"lalib.fields.base",
|
|
|
|
"lalib.fields.complex_",
|
|
|
|
"lalib.fields.galois",
|
|
|
|
"lalib.fields.rational",
|
|
|
|
"lalib.fields.real",
|
2024-09-10 01:57:02 +02:00
|
|
|
],
|
|
|
|
)
|
|
|
|
def test_docstrings(module):
|
|
|
|
"""Test code snippets within the package with `xdoctest`."""
|
|
|
|
result = xdoctest.doctest_module(module, "all")
|
|
|
|
|
|
|
|
assert result["n_failed"] == 0
|