From 12c347f6cec8a08b645b7d734928fb6b923d8968 Mon Sep 17 00:00:00 2001 From: Ben Rich Date: Thu, 21 Nov 2024 15:53:45 -0700 Subject: [PATCH] input/output utils testing separation --- tests/io/jdftx/test_input_utils.py | 14 ++++++++++++++ .../jdftx/{test_utils.py => test_output_utils.py} | 10 ---------- 2 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 tests/io/jdftx/test_input_utils.py rename tests/io/jdftx/{test_utils.py => test_output_utils.py} (86%) diff --git a/tests/io/jdftx/test_input_utils.py b/tests/io/jdftx/test_input_utils.py new file mode 100644 index 00000000000..ab01badfd94 --- /dev/null +++ b/tests/io/jdftx/test_input_utils.py @@ -0,0 +1,14 @@ +from __future__ import annotations + +import pytest + +from pymatgen.io.jdftx._input_utils import flatten_list + + +def test_flatten_list(): + assert flatten_list("", [1, 2, 3]) == [1, 2, 3] + assert flatten_list("", [1, [2, 3]]) == [1, 2, 3] + assert flatten_list("", [1, [2, [3]]]) == [1, 2, 3] + assert flatten_list("", [1, [2, [3, [4]]]]) == [1, 2, 3, 4] + with pytest.raises(TypeError): + flatten_list("", 1) diff --git a/tests/io/jdftx/test_utils.py b/tests/io/jdftx/test_output_utils.py similarity index 86% rename from tests/io/jdftx/test_utils.py rename to tests/io/jdftx/test_output_utils.py index b260c09c573..e4178eadf7c 100644 --- a/tests/io/jdftx/test_utils.py +++ b/tests/io/jdftx/test_output_utils.py @@ -2,20 +2,10 @@ import pytest -from pymatgen.io.jdftx._input_utils import flatten_list from pymatgen.io.jdftx._output_utils import find_first_range_key, get_start_lines, multi_getattr, multi_hasattr from pymatgen.io.jdftx.joutstructures import _get_joutstructures_start_idx -def test_flatten_list(): - assert flatten_list("", [1, 2, 3]) == [1, 2, 3] - assert flatten_list("", [1, [2, 3]]) == [1, 2, 3] - assert flatten_list("", [1, [2, [3]]]) == [1, 2, 3] - assert flatten_list("", [1, [2, [3, [4]]]]) == [1, 2, 3, 4] - with pytest.raises(TypeError): - flatten_list("", 1) - - def test_get_start_lines(): with pytest.raises(ValueError, match="Outfile parser fed an empty file."): get_start_lines([])