Skip to content

Commit

Permalink
Fix imgconverter tests
Browse files Browse the repository at this point in the history
Legacy assertRaisesRegexp got removed, use self.assertRaisesRegex

(cherry picked from commit 5dc579d)
  • Loading branch information
marmarek committed Jun 22, 2024
1 parent 8950fe7 commit 52d6b50
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions imgconverter/qubesimgconverter/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ def test_11_get_from_stream_malformed(self):
io = BytesIO('{0[0]} {0[1]}\n'.format(self.size).encode() +
self.rgba[:-1]) # one byte too short

with self.assertRaisesRegexp(ValueError, 'data length violation'):
with self.assertRaisesRegex(ValueError, 'data length violation'):
image = qubesimgconverter.Image.get_from_stream(io)

def test_12_get_from_stream_too_big(self):
io = BytesIO('{0[0]} {0[1]}\n'.format(self.size).encode() + self.rgba) # 2x2

with self.assertRaisesRegexp(ValueError, 'size constraint violation'):
with self.assertRaisesRegex(ValueError, 'size constraint violation'):
image = qubesimgconverter.Image.get_from_stream(io, max_width=1)

io.seek(0)
with self.assertRaisesRegexp(ValueError, 'size constraint violation'):
with self.assertRaisesRegex(ValueError, 'size constraint violation'):
image = qubesimgconverter.Image.get_from_stream(io, max_height=1)

async def test_20_get_from_stream_async(self):
Expand All @@ -79,19 +79,19 @@ async def test_22_get_from_stream_too_big(self):

reader = asyncio.StreamReader()
reader.feed_data(data)
with self.assertRaisesRegexp(ValueError, 'size constraint violation'):
with self.assertRaisesRegex(ValueError, 'size constraint violation'):
image = await qubesimgconverter.Image.get_from_stream_async(reader, max_width=1)

reader = asyncio.StreamReader()
reader.feed_data(data)
with self.assertRaisesRegexp(ValueError, 'size constraint violation'):
with self.assertRaisesRegex(ValueError, 'size constraint violation'):
image = await qubesimgconverter.Image.get_from_stream_async(reader, max_height=1)

async def test_23_get_from_stream_header_too_long(self):
data = '{0[0]} {0[1]}\n'.format(self.size).encode() + self.rgba # 2x2
reader = asyncio.StreamReader()
reader.feed_data(b'x' * 20 + b'\n')
with self.assertRaisesRegexp(ValueError, 'Header too long'):
with self.assertRaisesRegex(ValueError, 'Header too long'):
image = await qubesimgconverter.Image.get_from_stream_async(reader)


Expand Down

0 comments on commit 52d6b50

Please sign in to comment.