Add tests for LAMMPS exceptions in Python
This commit is contained in:
@ -18,6 +18,7 @@ try:
|
|||||||
machine = ""
|
machine = ""
|
||||||
lmp = lammps(name=machine)
|
lmp = lammps(name=machine)
|
||||||
has_mpi = lmp.has_mpi_support
|
has_mpi = lmp.has_mpi_support
|
||||||
|
has_exceptions = lmp.has_exceptions
|
||||||
lmp.close()
|
lmp.close()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@ -57,5 +58,32 @@ class PythonOpen(unittest.TestCase):
|
|||||||
self.assertEqual(lmp.opened,1)
|
self.assertEqual(lmp.opened,1)
|
||||||
lmp.close()
|
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__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user