add c/python unit tests for lammps_error()

This commit is contained in:
Axel Kohlmeyer
2022-09-23 18:59:29 -04:00
parent 86d1aacf7e
commit a94cfe175b
2 changed files with 41 additions and 2 deletions

View File

@ -45,11 +45,21 @@ class PythonOpen(unittest.TestCase):
def testWithArgs(self):
"""Create LAMMPS instance with a few arguments"""
lmp=lammps(name=self.machine,
cmdargs=['-nocite','-sf','opt','-log','none'])
lmp=lammps(name=self.machine,cmdargs=['-nocite','-sf','opt','-log','none'])
self.assertIsNot(lmp.lmp,None)
self.assertEqual(lmp.opened,1)
def testError(self):
"""Print warning message through LAMMPS Error class"""
lmp=lammps(name=self.machine,cmdargs=['-nocite','-log','none','-screen','tmp.error.output'])
lmp.error(0,'test_warning')
lmp.close()
with open('tmp.error.output','r') as f:
output = f.read()
self.assertTrue('LAMMPS' in output)
self.assertTrue('Total wall time' in output)
self.assertTrue('WARNING: test_warning' in output)
def testContextManager(self):
"""Automatically clean up LAMMPS instance"""
with lammps(name=self.machine) as lmp: