Skip to content

Commit

Permalink
simplify skip mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Nov 30, 2024
1 parent a2711c8 commit 3f5d2cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
7 changes: 3 additions & 4 deletions tests/command_line/test_enumlib_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
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")
enumlib_present = enum_cmd and makestr_cmd
ENUM_CMD = which("enum.x") or which("multienum.x")
MAKESTR_CMD = which("makestr.x") or which("makeStr.x") or which("makeStr.py")


@pytest.mark.skipif(not enumlib_present, reason="enum_lib not present.")
@pytest.mark.skipif(not (ENUM_CMD and MAKESTR_CMD), reason="enumlib not present.")
class TestEnumlibAdaptor(PymatgenTest):
def test_init(self):
struct = self.get_structure("LiFePO4")
Expand Down
16 changes: 7 additions & 9 deletions tests/command_line/test_gulp_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@

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. Right now, it is compiled against libgfortran3, which is no longer supported in the new
# Ubuntu 20.04.
gulp_present = False
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)


@pytest.mark.skipif(not gulp_present, reason="gulp not present.")
class TestGulpCaller:
def test_run(self):
mgo_lattice = np.eye(3) * 4.212
Expand Down Expand Up @@ -104,7 +106,6 @@ 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")
Expand Down Expand Up @@ -275,7 +276,6 @@ 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
Expand Down Expand Up @@ -327,7 +327,6 @@ 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")
Expand Down Expand Up @@ -355,7 +354,6 @@ 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")
Expand Down

0 comments on commit 3f5d2cc

Please sign in to comment.