nkululeko
nkululeko copied to clipboard
Add unit tests
Here is an example
- Add test parameters
- Test for expected value
- Add
tests/test_to_db.py
:
import numpy as np
import pytest
import spmath
@pytest.mark.parametrize(
'x, expected_y',
[
(2, 6.0206),
(.5, -6.0206),
(0, -np.Inf),
(-1, np.nan),
],
)
def test_to_db(x, expected_y):
y = spmath.to_db(x)
np.testing.assert_allclose(y, expected_y)