From aabbf5dc533ecedd9461189d4c48ce7a07997bd7 Mon Sep 17 00:00:00 2001 From: Han Wang Date: Tue, 7 May 2024 12:10:48 +0800 Subject: [PATCH] test: skip test of electronic_configuration_embedding if mendeleev is not installed --- .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"]