From df345ec1172241ef1e3ab4d485dd2488a416a2a0 Mon Sep 17 00:00:00 2001 From: Han Wang <92130845+wanghan-iapcm@users.noreply.github.com> Date: Tue, 7 May 2024 12:45:53 +0800 Subject: [PATCH] test: skip test of electronic_configuration_embedding if mendeleev is not installed (#3755) ## Summary by CodeRabbit - **Chores** - Updated the pre-commit hooks to a newer version for improved performance and bug fixes. - **Tests** - Enhanced test reliability by skipping certain tests if the required `mendeleev` module is not available. Co-authored-by: Han Wang --- .pre-commit-config.yaml | 2 +- source/tests/common/test_econf_embd.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 90ce425b14..a265a1312e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: exclude: ^source/3rdparty - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.4.2 + rev: v0.4.3 hooks: - id: ruff args: ["--fix"] diff --git a/source/tests/common/test_econf_embd.py b/source/tests/common/test_econf_embd.py index 97ac450c10..e2f314e460 100644 --- a/source/tests/common/test_econf_embd.py +++ b/source/tests/common/test_econf_embd.py @@ -6,7 +6,15 @@ make_econf_embedding, ) +try: + import mendeleev # noqa: F401 + has_mendeleev = True +except ImportError: + has_mendeleev = False + + +@unittest.skipIf(not has_mendeleev, "does not have mendeleev installed, skip the UTs.") class TestEConfEmbd(unittest.TestCase): def test_fe(self): res = make_econf_embedding(["Fe"], flatten=False)["Fe"]