Skip to content

Commit

Permalink
Change test pattern of writing to existing files
Browse files Browse the repository at this point in the history
Many tests were writing to temporary files that already exist, which is
not a supported workflow.
  • Loading branch information
quintusdias committed Sep 22, 2022
1 parent 53e0c4d commit d68d5ee
Show file tree
Hide file tree
Showing 5 changed files with 440 additions and 445 deletions.
11 changes: 8 additions & 3 deletions glymur/jp2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,12 +851,17 @@ def _write(self, img_array):
in memory.
"""
if version.openjpeg_version < '2.3.0':
msg = ("You must have at least version 2.3.0 of OpenJPEG "
"in order to write images.")
msg = (
"You must have at least version 2.3.0 of OpenJPEG in order to "
"write images."
)
raise RuntimeError(msg)

if hasattr(self, '_cparams'):
msg = "You cannot write image data to a JPEG 2000 file that already exists."
msg = (
"You cannot write image data to a JPEG 2000 file "
"that already exists."
)
raise RuntimeError(msg)

self._determine_colorspace()
Expand Down
5 changes: 2 additions & 3 deletions tests/test_cinema.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ def test_cinema2K_bad_frame_rate(self):
EXPECTED RESULT: ValueError
"""
with open(self.temp_j2k_filename, mode='wb') as tfile:
with self.assertRaises(ValueError):
Jp2k(tfile.name, data=self.jp2_data, cinema2k=36)
with self.assertRaises(ValueError):
Jp2k(self.temp_j2k_filename, data=self.jp2_data, cinema2k=36)

def test_NR_ENC_X_6_2K_24_FULL_CBR_CIRCLE_000_tif_17_encode(self):
"""
Expand Down
Loading

0 comments on commit d68d5ee

Please sign in to comment.