From 09e10c0465370f0873194bdc3804c7fcbca3feea Mon Sep 17 00:00:00 2001 From: simple-is-great <103080930+simple-is-great@users.noreply.github.com> Date: Sat, 2 Nov 2024 17:27:07 +0900 Subject: [PATCH] gh-125522: Remove bare except in test_zlib.test_flushes (gh-126321) (cherry picked from commit cfb1b2f0cb999558a30e61a9e1a62fdb7f55f6a4) Co-authored-by: simple-is-great <103080930+simple-is-great@users.noreply.github.com> --- Lib/test/test_zlib.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index 8654b93ec64ac8..9611a0d2d02e46 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -506,20 +506,16 @@ def test_flushes(self): for sync in sync_opt: for level in range(10): - try: + with self.subTest(sync=sync, level=level): obj = zlib.compressobj( level ) a = obj.compress( data[:3000] ) b = obj.flush( sync ) c = obj.compress( data[3000:] ) d = obj.flush() - except: - print("Error for flush mode={}, level={}" - .format(sync, level)) - raise - self.assertEqual(zlib.decompress(b''.join([a,b,c,d])), - data, ("Decompress failed: flush " - "mode=%i, level=%i") % (sync, level)) - del obj + self.assertEqual(zlib.decompress(b''.join([a,b,c,d])), + data, ("Decompress failed: flush " + "mode=%i, level=%i") % (sync, level)) + del obj @unittest.skipUnless(hasattr(zlib, 'Z_SYNC_FLUSH'), 'requires zlib.Z_SYNC_FLUSH')