From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sat, 2 Nov 2024 08:49:32 +0000 (+0100) Subject: [3.12] gh-125522: Remove bare except in test_zlib.test_flushes (gh-126321) (gh-126328) X-Git-Tag: v3.12.8~121 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eecea8f64a8873c1466d4b81f4bd398b835b6cbf;p=thirdparty%2FPython%2Fcpython.git [3.12] gh-125522: Remove bare except in test_zlib.test_flushes (gh-126321) (gh-126328) 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> --- diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index 8654b93ec64a..9611a0d2d02e 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -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')