Skip to content

Commit

Permalink
trying to cover line 165-165 in unit test. this refs #294
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanBilheux committed Mar 2, 2024
1 parent 84ac71b commit 813571a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/imars3d/backend/dataio/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ def __call__(self, **params):
)

elif sigs.intersection(ref) == {"files", "dir"}:
logger.error("Files and dir cannot be used at the same time")
raise ValueError("Mix usage of allowed signature.")
logger.error("Other cases of files and dir cannot be used at the same time")
raise ValueError("Mix signatures not allowed")

Check warning on line 195 in src/imars3d/backend/dataio/data.py

View check run for this annotation

Codecov / codecov/patch

src/imars3d/backend/dataio/data.py#L194-L195

Added lines #L194 - L195 were not covered by tests

elif sigs.intersection(ref) == {"files"}:
logger.debug("Load by file list")
Expand Down
13 changes: 6 additions & 7 deletions tests/unit/backend/dataio/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ def test_load_data(
# error_0: incorrect input argument types
with pytest.raises(ValueError):
load_data(ct_files=1, ob_files=[], dc_files=[])
load_data(ct_dir=1, ob_files=[], dc_files=[])
load_data(ct_dir="does_not_exist", ob_files=[], dc_files=[])
load_data(ct_dir=1, ob_files=[])
load_data(ct_files=[], ob_files=[], dc_files=[], ct_fnmatch=1)
load_data(ct_files=[], ob_files=[], dc_files=[], ob_fnmatch=1)
load_data(ct_files=[], ob_files=[], dc_files=[], dc_fnmatch=1)
Expand All @@ -111,15 +110,15 @@ def test_load_data(
# error_3: no valid signature found
with pytest.raises(ValueError):
load_data(ct_fnmatch=1)
# case_0: load data from file list
# case_0: load ct from directory, ob and dc from files
rst = load_data(ct_dir="/tmp", ob_files=["3", "4"], dc_files=["5", "6"])
np.testing.assert_almost_equal(np.array(rst).flatten(), np.arange(1, 5, dtype=float))
# case_1: load data from file list
rst = load_data(ct_files=["1", "2"], ob_files=["3", "4"], dc_files=["5", "6"])
np.testing.assert_almost_equal(np.array(rst).flatten(), np.arange(1, 5, dtype=float))
# case_1: load data from given directory
# case_2: load data from given directory
rst = load_data(ct_dir="/tmp", ob_dir="/tmp", dc_dir="/tmp")
np.testing.assert_almost_equal(np.array(rst).flatten(), np.arange(1, 5, dtype=float))
# case_2: load ct from directory, ob and dc from files
rst = load_data(ct_dir="/tmp", ob_files=["3", "4"], dc_files=["5", "6"])
np.testing.assert_almost_equal(np.array(rst).flatten(), np.arange(1, 5, dtype=float))


def test_forgiving_reader():
Expand Down

0 comments on commit 813571a

Please sign in to comment.