Skip to content

Add Unit Tests

Every new public function or class must have at least one test for accuracy and one edge case or failure mode.

particula//tests/_test.py (mirror the package directory)

The following text templates contain placeholders and are not executable. Use native held state and independent physical expectations for process tests; see example maintenance.

"""Docstring for the test module."""
import numpy as np # if needed
import pytest
from 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)
"""Docstring for the test module."""
import numpy as np # if needed
import pytest
from 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 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.