Skip to content

Commit

Permalink
TST: Test writing log file on convergence failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwthompson committed Oct 2, 2024
1 parent 273d27a commit 61b304d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions openff/interchange/_tests/unit_tests/components/test_packmol.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Units tests for openff.interchange.components._packmol
"""

import pathlib

import numpy
import pytest
from openff.toolkit.topology import Molecule
Expand Down Expand Up @@ -422,3 +424,22 @@ def test_load_100_000_atoms(self):
tolerance=1.0 * unit.angstrom,
mass_density=0.1 * unit.grams / unit.milliliters,
)

@pytest.mark.parametrize("use_local_path", [False, True])
def test_save_error_on_convergence_failure(self, use_local_path):
with pytest.raises(
PACKMOLRuntimeError,
match="failed with error code 173",
):
pack_box(
molecules=[Molecule.from_smiles("CCO")],
number_of_copies=[100],
box_shape=UNIT_CUBE,
mass_density=100 * unit.grams / unit.milliliters,
working_directory="." if use_local_path else None,
)

if use_local_path:
assert "STOP 173" in open("packmol_error.log").read()
else:
assert not pathlib.Path("packmol_error.log").is_file()

0 comments on commit 61b304d

Please sign in to comment.