From a02f475c3232b53b04632ad920867b67280a8221 Mon Sep 17 00:00:00 2001 From: Taher Chegini Date: Fri, 6 Oct 2023 22:39:13 -0400 Subject: [PATCH] MNT: Add new linters for checking print statement and pytest style. Then, fix the raised issues. [skip ci] --- conftest.py | 2 +- tests/test_exceptions.py | 6 +++--- tests/test_hydrosignatures.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/conftest.py b/conftest.py index 63a9755..7fb9259 100644 --- a/conftest.py +++ b/conftest.py @@ -4,7 +4,7 @@ @pytest.fixture(autouse=True) -def add_standard_imports(doctest_namespace): +def _add_standard_imports(doctest_namespace): """Add hydrosignatures namespace for doctest.""" import hydrosignatures as hs diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index 115691f..3dff862 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -7,6 +7,6 @@ def test_same_input_length(): - with pytest.raises(InputTypeError) as ex: - _ = hs.HydroSignatures(pd.Series(np.arange(10)), pd.Series(np.arange(11))) - assert "same length" in str(ex.value) + q_mmpt, p_mmpt = pd.Series(np.arange(10)), pd.Series(np.arange(11)) + with pytest.raises(InputTypeError, match="same length"): + _ = hs.HydroSignatures(q_mmpt, p_mmpt) diff --git a/tests/test_hydrosignatures.py b/tests/test_hydrosignatures.py index 0a3f920..41452d3 100644 --- a/tests/test_hydrosignatures.py +++ b/tests/test_hydrosignatures.py @@ -15,7 +15,7 @@ def assert_close(a: float, b: float) -> None: assert np.isclose(a, b, rtol=1e-3).all() -@pytest.fixture +@pytest.fixture() def datasets() -> Tuple[pd.Series, pd.Series, Dict[str, Any]]: df = pd.read_csv(Path("tests", "test_data.csv"), index_col=0, parse_dates=True) with Path("tests", "test_data.json").open("r") as f: @@ -23,7 +23,7 @@ def datasets() -> Tuple[pd.Series, pd.Series, Dict[str, Any]]: return df.q_mmpd, df.p_mmpd, sig_expected -@pytest.mark.speedup +@pytest.mark.speedup() def test_signatures(datasets): q_mmpd, p_mmpd, sig_expected = datasets sig = hs.HydroSignatures(q_mmpd, p_mmpd)