diff --git a/tests/test_geomopt_cli.py b/tests/test_geomopt_cli.py index 6c8a2c1a..c3450d3a 100644 --- a/tests/test_geomopt_cli.py +++ b/tests/test_geomopt_cli.py @@ -8,7 +8,7 @@ import yaml from janus_core.cli import app -from tests.utils import check_log_contents, read_atoms +from tests.utils import assert_log_contains, read_atoms DATA_PATH = Path(__file__).parent / "data" @@ -75,7 +75,7 @@ def test_log(tmp_path): ) assert result.exit_code == 0 - check_log_contents( + assert_log_contains( log_path, includes="Starting geometry optimization", excludes="Using filter" ) @@ -131,7 +131,9 @@ def test_fully_opt(tmp_path): ) assert result.exit_code == 0 - check_log_contents(log_path, includes=["Using filter", "hydrostatic_strain: False"]) + assert_log_contains( + log_path, includes=["Using filter", "hydrostatic_strain: False"] + ) atoms = read(results_path) expected = [5.68834069, 5.68893345, 5.68932555, 89.75938298, 90.0, 90.0] @@ -162,7 +164,7 @@ def test_fully_opt_and_vectors(tmp_path): ) assert result.exit_code == 0 - check_log_contents(log_path, includes=["Using filter", "hydrostatic_strain: True"]) + assert_log_contains(log_path, includes=["Using filter", "hydrostatic_strain: True"]) atoms = read(results_path) expected = [5.69139709, 5.69139709, 5.69139709, 89.0, 90.0, 90.0] @@ -192,7 +194,7 @@ def test_vectors_not_fully_opt(tmp_path): ) assert result.exit_code == 0 - check_log_contents(log_path, includes=["Using filter", "hydrostatic_strain: True"]) + assert_log_contains(log_path, includes=["Using filter", "hydrostatic_strain: True"]) def test_duplicate_traj(tmp_path): diff --git a/tests/test_log.py b/tests/test_log.py index 00c12a53..82aa4bc5 100644 --- a/tests/test_log.py +++ b/tests/test_log.py @@ -3,7 +3,7 @@ import yaml from janus_core.log import config_logger -from tests.utils import check_log_contents +from tests.utils import assert_log_contains def test_multiline_log(tmp_path): @@ -27,4 +27,4 @@ def test_multiline_log(tmp_path): assert log_dicts[0]["level"] == "INFO" assert len(log_dicts[0]["message"]) == 3 - check_log_contents(log_path, includes=["Line 1", "Line 4"]) + assert_log_contains(log_path, includes=["Line 1", "Line 4"]) diff --git a/tests/test_md_cli.py b/tests/test_md_cli.py index c4c4c096..86b4167a 100644 --- a/tests/test_md_cli.py +++ b/tests/test_md_cli.py @@ -9,7 +9,7 @@ import yaml from janus_core.cli import app -from tests.utils import check_log_contents +from tests.utils import assert_log_contains DATA_PATH = Path(__file__).parent / "data" @@ -105,7 +105,7 @@ def test_log(tmp_path): ) assert result.exit_code == 0 - check_log_contents(log_path, includes=["Starting molecular dynamics simulation"]) + assert_log_contains(log_path, includes=["Starting molecular dynamics simulation"]) with open(tmp_path / "nvt-T300-stats.dat", encoding="utf8") as stats_file: lines = stats_file.readlines() diff --git a/tests/test_singlepoint_cli.py b/tests/test_singlepoint_cli.py index cd9e25cc..00ae64e5 100644 --- a/tests/test_singlepoint_cli.py +++ b/tests/test_singlepoint_cli.py @@ -7,7 +7,7 @@ import yaml from janus_core.cli import app -from tests.utils import check_log_contents, read_atoms +from tests.utils import assert_log_contains, read_atoms DATA_PATH = Path(__file__).parent / "data" @@ -192,7 +192,7 @@ def test_log(tmp_path): ) assert result.exit_code == 0 - check_log_contents(log_path, includes=["Starting single point calculation"]) + assert_log_contains(log_path, includes=["Starting single point calculation"]) def test_summary(tmp_path): diff --git a/tests/utils.py b/tests/utils.py index 42135f29..65749e0c 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,7 +1,7 @@ """Utility functions for tests.""" from pathlib import Path -from typing import Optional, Union +from typing import Union from ase import Atoms from ase.io import read @@ -35,8 +35,9 @@ def read_atoms(path: Path) -> Union[Atoms, None]: return atoms if atoms else None -def check_log_contents( - log_path: PathLike, *, +def assert_log_contains( + log_path: PathLike, + *, includes: MaybeSequence[str] = (), excludes: MaybeSequence[str] = (), ) -> None: