Skip to content

Commit

Permalink
Trying to make a correctly failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiisoup committed Nov 11, 2024
1 parent a714fc0 commit d550c0d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Empty file added testings/corrupt_data2/tmp.sif
Empty file.
19 changes: 19 additions & 0 deletions testings/test_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
files = os.listdir(d)
corrupt_filenames = [d + f for f in files if f[-4:] in [".sif", ".SIF"]]

corrupt_filenames2 = [THIS_DIR + '/corrupt_data2/tmp.sif']

d = THIS_DIR + "/spool_data/"
spool_file_dirs = []
for e in [d + "/data_corrupted/"]:
Expand Down Expand Up @@ -191,6 +193,13 @@ def test_corrupt_file(filename):
with pytest.raises(ValueError) as e_info:
data, info = sif_parser.np_open(filename)

# try open with a write mode to make sure the file is closed
try:
data, info = sif_parser.np_open(filename)
except ValueError:
with open(filename, 'a') as f:
assert f.writable()

with pytest.warns(UserWarning, match="corrupt."):
data, info = sif_parser.np_open(filename, ignore_corrupt=True)

Expand All @@ -201,6 +210,16 @@ def test_corrupt_file(filename):
data = sif_parser.xr_open(filename, ignore_corrupt=True)


@pytest.mark.parametrize("filename", corrupt_filenames2)
def test_corrupt_file2(filename):
# try open with a write mode to make sure the file is closed
try:
data, info = sif_parser.np_open(filename)
except (ValueError, SyntaxError):
with open(filename, 'a') as f:
assert f.writable()


@pytest.mark.parametrize(
("filename", "raman_wavelength"),
[
Expand Down

0 comments on commit d550c0d

Please sign in to comment.