diff --git a/unittest/python/python-open.py b/unittest/python/python-open.py index 6ad7d335d5..6153e032e3 100644 --- a/unittest/python/python-open.py +++ b/unittest/python/python-open.py @@ -18,6 +18,7 @@ try: machine = "" lmp = lammps(name=machine) has_mpi = lmp.has_mpi_support + has_exceptions = lmp.has_exceptions lmp.close() except: pass @@ -57,5 +58,32 @@ class PythonOpen(unittest.TestCase): self.assertEqual(lmp.opened,1) lmp.close() + @unittest.skipIf(not has_exceptions,"Skipping death test since LAMMPS isn't compiled with exception support") + def testUnknownCommand(self): + lmp = lammps(name=self.machine) + + with self.assertRaisesRegex(Exception, "ERROR: Unknown command: write_paper"): + lmp.command("write_paper") + + lmp.close() + + @unittest.skipIf(not has_exceptions,"Skipping death test since LAMMPS isn't compiled with exception support") + def testUnknownCommandInList(self): + lmp = lammps(name=self.machine) + + with self.assertRaisesRegex(Exception, "ERROR: Unknown command: write_paper"): + lmp.commands_list(["write_paper"]) + + lmp.close() + + @unittest.skipIf(not has_exceptions,"Skipping death test since LAMMPS isn't compiled with exception support") + def testUnknownCommandInList(self): + lmp = lammps(name=self.machine) + + with self.assertRaisesRegex(Exception, "ERROR: Unknown command: write_paper"): + lmp.commands_string("write_paper") + + lmp.close() + if __name__ == "__main__": unittest.main()