Files
beta_shape_pnpi/tests/quality/test_api_screening.py
T
unzhakov 4b08df3873 test: create new test architecture with shared property/API tests
- Add tests/common/ with parametrized property tests (positivity, shape, NaN, stability)
- Add tests/physics/ with unique physics behavior tests for 6 correction components
- Add tests/quality/ with API contract tests for 6 correction components
- Add pytest markers in pyproject.toml: property, physics, api, quality, integration
- New tests: 94 tests passing (physics + quality + common helpers)
- Old tests in tests/ root still present — migration in progress
- Total: 261 tests collected (230 old + 94 new - 63 duplicates removed)

The shared helpers eliminate 18 duplicate test patterns across correction
components. Each component now has:
  - tests/physics/test_<name>.py — unique physics behavior
  - tests/quality/test_api_<name>.py — API contract + shared property checks
  - tests/common/test_property_tests.py — shared helpers (imported, not duplicated)
2026-05-15 15:04:52 +03:00

49 lines
1.5 KiB
Python

"""
Code quality / API tests for ScreeningCorrection.
Shared property tests in tests/common/test_property_tests.py.
"""
import numpy as np
import pytest
from beta_spectrum.components.fermi import FermiFunction
from beta_spectrum.components.screening import ScreeningCorrection
class TestScreeningAPI:
@pytest.mark.api
def test_callable(self):
ff = FermiFunction(Z=20, A=40)
sc = ScreeningCorrection(ff)
assert callable(sc)
result = sc(np.array([2.0]))
assert isinstance(result, np.ndarray)
@pytest.mark.api
def test_repr(self):
ff = FermiFunction(Z=20, A=40)
sc = ScreeningCorrection(ff)
assert "Screening" in repr(sc)
class TestScreeningProperties:
@pytest.mark.property
@pytest.mark.parametrize("W", [
[2.0],
np.linspace(1.02, 3.0, 20),
])
def test_positive(self, W):
ff = FermiFunction(Z=40, A=95)
sc = ScreeningCorrection(ff)
from tests.common.test_property_tests import _test_positive_values
_test_positive_values(sc, W, component_name="ScreeningCorrection")
@pytest.mark.quality
@pytest.mark.parametrize("n", [1, 5, 100])
def test_shape(self, n):
ff = FermiFunction(Z=20, A=40)
sc = ScreeningCorrection(ff)
W = np.linspace(1.1, 3.0, n)
from tests.common.test_property_tests import _test_output_shape_preserved
_test_output_shape_preserved(sc, W, component_name="ScreeningCorrection")