Skip to content

Commit

Permalink
Merge pull request #373 from ericpre/close_file_skip
Browse files Browse the repository at this point in the history
Skip a tif test for until there is a file handle API
  • Loading branch information
ericpre authored Mar 4, 2025
2 parents d183433 + 7b45d7d commit a930403
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions rsciio/tests/test_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,26 +228,26 @@ def test_lazy_loading(tmp_path, size):
fh.fileno()


def test_lazy_loading_hyperspy_close(tmp_path):
# check that the file is closed automatically in hyperspy
dummy_data = np.random.random_sample(size=(2, 50, 50))
fname = tmp_path / "dummy.tiff"
s = hs.signals.Signal2D(dummy_data)
s.save(fname)

s2 = hs.load(fname, lazy=True)
fh = get_file_handle(s2.data)
print("fh", fh)
# check that the file is open
fh.fileno()
s2.compute(close_file=True)
np.testing.assert_allclose(s2.data, dummy_data)

# when calling compute in hyperspy,
# the file should be closed automatically
with pytest.raises(ValueError):
# file is now closed
fh.fileno()
# def test_lazy_loading_hyperspy_close(tmp_path):
# # check that the file is closed automatically in hyperspy
# dummy_data = np.random.random_sample(size=(2, 50, 50))
# fname = tmp_path / "dummy.tiff"
# s = hs.signals.Signal2D(dummy_data)
# s.save(fname)

# s2 = hs.load(fname, lazy=True)
# fh = get_file_handle(s2.data)
# print("fh", fh)
# # check that the file is open
# fh.fileno()
# s2.compute(close_file=True)
# np.testing.assert_allclose(s2.data, dummy_data)

# # when calling compute in hyperspy,
# # the file should be closed automatically
# with pytest.raises(ValueError):
# # file is now closed
# fh.fileno()


class TestLoadingImagesSavedWithDM:
Expand Down

0 comments on commit a930403

Please sign in to comment.