diff --git a/tests/command_line/test_enumlib_caller.py b/tests/command_line/test_enumlib_caller.py index aa3cebff4a3..010bb0bd1b8 100644 --- a/tests/command_line/test_enumlib_caller.py +++ b/tests/command_line/test_enumlib_caller.py @@ -1,5 +1,6 @@ from __future__ import annotations +import unittest from shutil import which import numpy as np @@ -13,11 +14,12 @@ from pymatgen.transformations.standard_transformations import SubstitutionTransformation from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -ENUM_CMD = which("enum.x") or which("multienum.x") -MAKESTR_CMD = which("makestr.x") or which("makeStr.x") or which("makeStr.py") +enum_cmd = which("enum.x") or which("multienum.x") +makestr_cmd = which("makestr.x") or which("makeStr.x") or which("makeStr.py") +enumlib_present = enum_cmd and makestr_cmd -@pytest.mark.skipif(not (ENUM_CMD and MAKESTR_CMD), reason="enumlib not present.") +@pytest.mark.skipif(not enumlib_present, reason="enum_lib not present.") class TestEnumlibAdaptor(PymatgenTest): def test_init(self): struct = self.get_structure("LiFePO4") @@ -117,7 +119,7 @@ def test_partial_disorder(self): for struct in structures: assert struct.formula == "Ca12 Al8 Si4 Ge8 O48" - @pytest.mark.skip("Fails seemingly at random.") + @unittest.skip("Fails seemingly at random.") def test_timeout(self): struct = Structure.from_file(filename=f"{TEST_FILES_DIR}/cif/garnet.cif") SpacegroupAnalyzer(struct, 0.1) diff --git a/tests/command_line/test_gulp_caller.py b/tests/command_line/test_gulp_caller.py index 18c3f05c268..9ff8c4bd10f 100644 --- a/tests/command_line/test_gulp_caller.py +++ b/tests/command_line/test_gulp_caller.py @@ -8,6 +8,7 @@ import os import sys +import unittest from shutil import which from unittest import TestCase @@ -29,15 +30,13 @@ TEST_DIR = f"{TEST_FILES_DIR}/command_line/gulp" -GULP_PRESENT = which("gulp") and os.getenv("GULP_LIB") and ("win" not in sys.platform) -# Disable GULP tests for now: it is compiled against `libgfortran3``, -# which is no longer supported in Ubuntu 20.04 and onwards. -GULP_PRESENT = False - -if not GULP_PRESENT: - pytest.skip(reason="GULP not available", allow_module_level=True) +gulp_present = which("gulp") and os.getenv("GULP_LIB") and ("win" not in sys.platform) +# disable gulp tests for now. Right now, it is compiled against libgfortran3, which is no longer supported in the new +# Ubuntu 20.04. +gulp_present = False +@pytest.mark.skipif(not gulp_present, reason="gulp not present.") class TestGulpCaller: def test_run(self): mgo_lattice = np.eye(3) * 4.212 @@ -106,6 +105,7 @@ def test_decimal(self): caller.run(buckingham_input) +@pytest.mark.skipif(not gulp_present, reason="gulp not present.") class TestGulpIO(TestCase): def setUp(self): self.structure = Structure.from_file(f"{VASP_IN_DIR}/POSCAR_Al12O18") @@ -271,11 +271,12 @@ def test_get_relaxed_structure(self): assert struct.lattice.a == 4.212 assert struct.lattice.alpha == 90 - @pytest.mark.skip("Test later") + @unittest.skip("Test later") def test_tersoff_input(self): self.gio.tersoff_input(self.structure) +@pytest.mark.skipif(not gulp_present, reason="gulp not present.") class TestGlobalFunctions(TestCase): def setUp(self): mgo_latt = np.eye(3) * 4.212 @@ -327,6 +328,7 @@ def test_get_energy_relax_structure_buckingham(self): assert site_len == len(self.mgo_uc) +@pytest.mark.skipif(not gulp_present, reason="gulp not present.") class TestBuckinghamPotentialLewis(TestCase): def setUp(self): self.bpl = BuckinghamPotential("lewis") @@ -354,6 +356,7 @@ def test_spring(self): assert self.bpl.spring_dict["O"] != "" +@pytest.mark.skipif(not gulp_present, reason="gulp not present.") class TestBuckinghamPotentialBush(TestCase): def setUp(self): self.bpb = BuckinghamPotential("bush") diff --git a/tests/core/test_surface.py b/tests/core/test_surface.py index 0527fc671b0..80f1819da2f 100644 --- a/tests/core/test_surface.py +++ b/tests/core/test_surface.py @@ -2,9 +2,9 @@ import json import os +import unittest import numpy as np -import pytest from numpy.testing import assert_allclose from pytest import approx @@ -697,7 +697,7 @@ def test_get_d(self): s2 = recon2.get_unreconstructed_slabs()[0] assert get_d(s1) == approx(get_d(s2)) - @pytest.mark.skip("This test relies on neighbor orders and is hard coded. Disable temporarily") + @unittest.skip("This test relies on neighbor orders and is hard coded. Disable temporarily") def test_previous_reconstructions(self): # Test to see if we generated all reconstruction types correctly and nothing changes diff --git a/tests/io/test_zeopp.py b/tests/io/test_zeopp.py index 28bc18aad8c..819f13a2ee8 100644 --- a/tests/io/test_zeopp.py +++ b/tests/io/test_zeopp.py @@ -1,5 +1,6 @@ from __future__ import annotations +import unittest from unittest import TestCase import pytest @@ -166,7 +167,7 @@ def test_get_voronoi_nodes(self): assert isinstance(vor_face_center_struct, Structure) -@pytest.mark.skip("TODO: file free_sph.cif not present") +@unittest.skip("TODO: file free_sph.cif not present") class TestGetFreeSphereParams(TestCase): def setUp(self): filepath = f"{TEST_FILES_DIR}/cif/free_sph.cif" diff --git a/tests/io/vasp/test_sets.py b/tests/io/vasp/test_sets.py index 6b4f9ceebdb..4509e1b95f5 100644 --- a/tests/io/vasp/test_sets.py +++ b/tests/io/vasp/test_sets.py @@ -2,6 +2,7 @@ import hashlib import os +import unittest from glob import glob from zipfile import ZipFile @@ -1606,7 +1607,7 @@ def test_user_incar_settings(self): assert not vis.incar["LASPH"], "LASPH user setting not applied" assert vis.incar["VDW_SR"] == 1.5, "VDW_SR user setting not applied" - @pytest.mark.skipif(not os.path.exists(TEST_DIR), reason="Test files are not present.") + @unittest.skipIf(not os.path.exists(TEST_DIR), "Test files are not present.") def test_from_prev_calc(self): prev_run = os.path.join(TEST_DIR, "fixtures", "relaxation") @@ -1623,7 +1624,7 @@ def test_from_prev_calc(self): assert "VDW_A2" in vis_bj.incar assert "VDW_S8" in vis_bj.incar - @pytest.mark.skipif(not os.path.exists(TEST_DIR), reason="Test files are not present.") + @unittest.skipIf(not os.path.exists(TEST_DIR), "Test files are not present.") def test_override_from_prev_calc(self): prev_run = os.path.join(TEST_DIR, "fixtures", "relaxation")