]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-125522: Remove bare except in test_zlib.test_flushes (gh-126321) (gh-126328)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 2 Nov 2024 08:49:32 +0000 (09:49 +0100)
committerGitHub <noreply@github.com>
Sat, 2 Nov 2024 08:49:32 +0000 (17:49 +0900)
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

index 8654b93ec64ac8d9239945d560937409d24ae014..9611a0d2d02e46b5216eeb038919054b615243ad 100644 (file)
@@ -506,20 +506,16 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
 
         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')