From 7cbc24151dbb648e687544dfa3a2048df8aa58dc Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 22 Aug 2024 23:08:52 -0400 Subject: [PATCH] tests: check examples (#4) Signed-off-by: Jinzhe Zeng Signed-off-by: Jinzhe Zeng --- pyproject.toml | 2 ++ tests/test_examples.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/test_examples.py diff --git a/pyproject.toml b/pyproject.toml index e14d60d..066bc24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ dependencies = [ "deepmd-kit[torch]>=3.0.0b2", "mace-torch>=0.3.5", "e3nn", + "dargs", ] requires-python = ">=3.9" readme = "README.md" @@ -45,6 +46,7 @@ repository = "https://github.com/njzjz/deepmd_mace" test = [ 'pytest', 'pytest-cov', + "dargs>=0.4.8", ] [tool.scikit-build] diff --git a/tests/test_examples.py b/tests/test_examples.py new file mode 100644 index 0000000..4d1688e --- /dev/null +++ b/tests/test_examples.py @@ -0,0 +1,28 @@ +"""Test examples.""" + +import json +from pathlib import Path + +import pytest +from dargs.check import check +from deepmd.utils.argcheck import gen_args + +from deepmd_mace.argcheck import mace_model_args # noqa: F401 + +example_path = Path(__file__).parent.parent / "examples" + +examples = ( + example_path / "water" / "mace" / "input.json", + example_path / "dprc" / "mace" / "input.json", +) + + +@pytest.mark.parametrize("example", examples) +def test_examples(example: Path) -> None: + """Check whether examples meet arguments.""" + with example.open("r") as f: + data = json.load(f) + check( + gen_args(), + data, + )