Commit 813571af authored by Bilheux, Jean-Christophe's avatar Bilheux, Jean-Christophe
Browse files

trying to cover line 165-165 in unit test. this refs #294

parent 84ac71bc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -191,8 +191,8 @@ class load_data(param.ParameterizedFunction):
            )

        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")

        elif sigs.intersection(ref) == {"files"}:
            logger.debug("Load by file list")
+6 −7
Original line number Diff line number Diff line
@@ -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)
@@ -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():