Skip to content

Commit

Permalink
Unittest for vasprun.
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep committed Aug 11, 2014
1 parent 4581578 commit 2e09b02
Show file tree
Hide file tree
Showing 3 changed files with 48,176 additions and 7 deletions.
4 changes: 1 addition & 3 deletions custodian/tests/test_custodian.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ def test_unrecoverable(self):
c = Custodian([ExampleHandler2(params)],
[ExampleJob(i, params) for i in xrange(njobs)],
max_errors=njobs, log_file=None)
output = c.run()
#Because this is unrecoverable, there should only be one output.
self.assertEqual(len(output), 1)
self.assertRaises(RuntimeError, c.run)

def tearDown(self):
for f in glob.glob("custodian.*.tar.gz"):
Expand Down
25 changes: 21 additions & 4 deletions custodian/vasp/tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from custodian.vasp.handlers import VaspErrorHandler, \
UnconvergedErrorHandler, MeshSymmetryErrorHandler, WalltimeHandler, \
MaxForceErrorHandler
MaxForceErrorHandler, BadVasprunXMLHandler
from pymatgen.io.vaspio import Incar, Poscar


Expand Down Expand Up @@ -220,14 +220,14 @@ def test_check_correct(self):
self.assertEqual(d["errors"], ['MaxForce'])

os.remove(os.path.join(subdir, "error.1.tar.gz"))

incar = Incar.from_file('INCAR')
poscar = Poscar.from_file('POSCAR')
contcar = Poscar.from_file('CONTCAR')

shutil.move("INCAR.orig", "INCAR")
shutil.move("POSCAR.orig", "POSCAR")

self.assertEqual(poscar.structure, contcar.structure)
self.assertAlmostEqual(incar['EDIFF'], 0.00075)

Expand Down Expand Up @@ -283,5 +283,22 @@ def tearDownClass(cls):
os.chdir(cwd)



class BadVasprunXMLHandlerTest(unittest.TestCase):


def test_check_and_correct(self):
os.chdir(os.path.join(test_dir, "bad_vasprun"))
h = BadVasprunXMLHandler()
self.assertTrue(h.check())

#Unconverged still has a valid vasprun.
os.chdir(os.path.join(test_dir, "unconverged"))
self.assertFalse(h.check())

@classmethod
def tearDownClass(cls):
os.chdir(cwd)

if __name__ == "__main__":
unittest.main()
Loading

0 comments on commit 2e09b02

Please sign in to comment.