Add Unit Tests
Philosophy
Section titled “Philosophy”Every new public function or class must have at least one test for accuracy and one edge case or failure mode.
Location
Section titled “Location”particula//tests/
The following text templates contain placeholders and are not executable. Use native held state and independent physical expectations for process tests; see example maintenance.
Template for Functions
Section titled “Template for Functions”"""Docstring for the test module."""import numpy as np # if neededimport pytestfrom particula.<area> import <symbol>
def test_<symbol>_accuracy(): """Docstring for the test.""" result = <symbol>(<valid_args>) assert np.isclose(result, <expected>)
@pytest.mark.parametrize("bad_input", [...])
def test_<symbol>_bad_inputs(bad_input): """Docstring for the test.""" with pytest.raises(ValueError): <symbol>(bad_input)Template for Classes
Section titled “Template for Classes”"""Docstring for the test module."""import numpy as np # if neededimport pytestfrom particula.<area> import <ClassName>
def test_<ClassName>_accuracy(): """Docstring for the test.""" obj = <ClassName>(<valid_args>) result = obj.<method_name>(<valid_args>) assert np.isclose(result, <expected>)
@pytest.mark.parametrize("bad_input", [...])def test_<ClassName>_bad_inputs(bad_input): """Docstring for the test.""" with pytest.raises(ValueError): <ClassName>(bad_input)Run locally
Section titled “Run locally”Run the package suite plus pytest examples_tests -q -Werror and
pytest scripts/tests -q -Werror when maintaining examples or infrastructure.
Focused assertions use --no-cov; obtain repository coverage only from the
full-package pytest --cov=particula --cov-report=term-missing --cov-fail-under=80 gate.