Skip to content

Commit 8b00059

Browse files
committed
tests: Change case 4 to FileNotFoundError.
1 parent e5685ca commit 8b00059

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

tests/test_load_image.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# expect file is found and correctly read
2121
("./KFe2As2-00838.tif", True),
2222
# case 4: non-existent file that incurred by mistype.
23-
("nonexistent_file.tif", False),
23+
("nonexistent_file.tif", FileNotFoundError),
2424
]
2525

2626

@@ -35,21 +35,17 @@ def test_load_image(input_path, expected, user_filesystem):
3535
shutil.copy(source_file, cwd_dir / "KFe2As2-00838.tif")
3636
shutil.copy(source_file, home_dir / "KFe2As2-00838.tif")
3737

38-
old_cwd = Path.cwd()
39-
os.chdir(home_dir)
40-
4138
try:
4239
cfg = type(
4340
"Cfg", (), {"fliphorizontal": True, "flipvertical": False}
4441
)()
4542
loader = LoadImage(cfg)
4643
actual = loader.loadImage(input_path)
47-
assert isinstance(actual, np.ndarray)
44+
expected = loader.loadImage(source_file)
45+
assert np.array_equal(actual, expected)
4846
except FileNotFoundError:
4947
pytest.raises(
5048
FileNotFoundError,
5149
match=r"file not found:"
5250
r" .*Please rerun specifying a valid filename\.",
5351
)
54-
finally:
55-
os.chdir(old_cwd)

0 commit comments

Comments
 (0)