Skip to content

Commit

Permalink
Increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-S-Rosen committed Jan 14, 2024
1 parent a4d0b0f commit 5bf2d24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/raspa_ase/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,10 @@ def _dict_to_str(d: dict[str, Any]) -> str:
"""
s = ""
for k, v in d.items():
s += f" {k} "
if isinstance(v, dict):
s += _dict_to_str(v)
s += f" {k}\n " + _dict_to_str(v)
elif isinstance(v, Iterable) and not isinstance(v, str):
s += _iterable_to_str(v)
s += f" {k} " + _iterable_to_str(v)
else:
s += f"{v}\n"
s += f" {k} {v}\n"
return s
7 changes: 5 additions & 2 deletions tests/utils/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@


def test_write_simulation_input(tmp_path):
parameters = {"a": 1, "b": [2, 3], "c": {"d": 4, "e": False}}
parameters = {"a": 1, "b": [2, 3], "c": {"d": 4, "e": False, "f": {"g": 5}}}
input_filepath = tmp_path / "simulation.input"
write_simulation_input(parameters, input_filepath)
assert input_filepath.read_text() == "a 1\nb 2 3\nc\n d 4\n e No\n"
assert (
input_filepath.read_text().strip()
== "a 1\nb 2 3\nc\n d 4\n e No\n f\n g 5"
)


def test_write_frameworks(tmp_path):
Expand Down

0 comments on commit 5bf2d24

Please sign in to comment.