Skip to content

Commit

Permalink
Adding unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwaroquiers committed Mar 12, 2024
1 parent ebeab48 commit 76fc923
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/turbomoleio/output/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,6 @@ def from_parser(cls, parser):
MP2Results.
"""
data = parser.mp2_results
print(data)
if not data or "energy" not in data or data["energy"] is None:
return None

Expand Down
6 changes: 3 additions & 3 deletions src/turbomoleio/output/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,13 +719,13 @@ def from_parser(cls, parser):
) = parser.get_split_jobex_parsers()

energy = gradient = relax = None
if exec_en in exec_to_out_obj:
if exec_en in exec_to_out_obj: # pragma: no branch (trivial)
energy = exec_to_out_obj[exec_en].from_parser(p_en)

if exec_grad in exec_to_out_obj:
if exec_grad in exec_to_out_obj: # pragma: no branch (trivial)
gradient = exec_to_out_obj[exec_grad].from_parser(p_grad)

if exec_relax in exec_to_out_obj:
if exec_relax in exec_to_out_obj: # pragma: no branch (trivial)
relax = exec_to_out_obj[exec_relax].from_parser(p_relax)

return cls(energy=energy, gradient=gradient, relax=relax)
Expand Down
15 changes: 15 additions & 0 deletions tests/output/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@
from pymatgen.core.structure import Molecule

from turbomoleio.output.files import (
EgradOutput,
EscfOnlyOutput,
EscfOutput,
GradOutput,
JobexOutput,
exec_to_out_obj,
)
from turbomoleio.output.parser import Parser
from turbomoleio.testing import ( # TESTS_CONFIGS_TM_VERSIONS,
TM_VERSIONS,
assert_almost_equal,
Expand Down Expand Up @@ -189,3 +192,15 @@ def generate_files(files=None, overwrite=False):
from monty.json import jsanitize

json.dump(jsanitize(parsed_data), f, indent=2)


def test_GradOutput_empty():
p = Parser("nothing here")
go = GradOutput.from_parser(p)
assert go is None


def test_EgradOutput_empty():
p = Parser("nothing here")
eo = EgradOutput.from_parser(p)
assert eo is None

0 comments on commit 76fc923

Please sign in to comment.