From ec1c6eba11613fb28f9f60067b6d21e7f64aa928 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 5 Oct 2022 20:14:56 -0400 Subject: [PATCH] we cannot test the Pizza.py dump class without the MOLECULE package --- unittest/python/python-pizza.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/unittest/python/python-pizza.py b/unittest/python/python-pizza.py index fd28ff9129..939c22a267 100644 --- a/unittest/python/python-pizza.py +++ b/unittest/python/python-pizza.py @@ -11,12 +11,21 @@ sys.path.insert(1,PIZZA_DIR) # dump class uses NumPy, so only load and test dump if NumPy is available has_numpy = False +has_molecule = False +machine = None +if 'LAMMPS_MACHINE_NAME' in os.environ: + machine=os.environ['LAMMPS_MACHINE_NAME'] +tmplmp = lammps(name=machine, cmdargs=['-nocite', '-log', 'none', '-echo', 'screen']) +has_molecule = tmplmp.has_package('MOLECULE') +tmplmp.close() + try: import numpy has_numpy = True import dump except: pass +do_dump_test = has_numpy and has_molecule import log @@ -116,11 +125,12 @@ class PythonDump(unittest.TestCase): if 'LAMMPS_MACHINE_NAME' in os.environ: machine=os.environ['LAMMPS_MACHINE_NAME'] self.lmp = lammps(name=machine, cmdargs=['-nocite', '-log', 'none', '-echo', 'screen']) + self.do_dump_test = self.lmp.has_package('MOLECULE') and has_numpy def tearDown(self): del self.lmp - @unittest.skipIf(not has_numpy,"Missing the NumPy python module") + @unittest.skipIf(not do_dump_test,"Missing the NumPy python module or MOLECULE package") def testDumpCustom(self): dumpfile = os.path.join(os.path.abspath('.'), 'dump.custom') self.lmp.command('shell cd ' + os.environ['TEST_INPUT_DIR'])