From 3461fa2b19f636a18d2e301f9c522cf8ee502d21 Mon Sep 17 00:00:00 2001 From: Jack Hindmarch Date: Wed, 25 May 2022 23:58:57 +0100 Subject: [PATCH 1/3] Fixing tests that fail when running with optimizations (`-O`) in `test_zipimport.py` --- Lib/test/test_zipimport.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py index 66789262dd6ca1..14318bf1e811bb 100644 --- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -654,7 +654,8 @@ def test(val): sys.path.insert(0, TEMP_ZIP) mod = importlib.import_module(TESTMOD) self.assertEqual(mod.test(1), 1) - self.assertRaises(AssertionError, mod.test, False) + if __debug__: + self.assertRaises(AssertionError, mod.test, False) def testImport_WithStuff(self): # try importing from a zipfile which contains additional From b451da29d2b0b72fdaab611060f2a58550e3a88d Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 25 May 2022 23:00:36 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Tests/2022-05-25-23-00-35.gh-issue-92886.Y-vrWj.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Tests/2022-05-25-23-00-35.gh-issue-92886.Y-vrWj.rst diff --git a/Misc/NEWS.d/next/Tests/2022-05-25-23-00-35.gh-issue-92886.Y-vrWj.rst b/Misc/NEWS.d/next/Tests/2022-05-25-23-00-35.gh-issue-92886.Y-vrWj.rst new file mode 100644 index 00000000000000..93c1ffe33f28a6 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2022-05-25-23-00-35.gh-issue-92886.Y-vrWj.rst @@ -0,0 +1 @@ +Fixing tests that fail when running with optimizations (``-O``) in ``test_zipimport.py`` From a890b253192e74674a8803dc640128b3044f2b67 Mon Sep 17 00:00:00 2001 From: Jack Hindmarch Date: Tue, 7 Jun 2022 21:13:13 +0100 Subject: [PATCH 3/3] Add assertion to testDefaultOptimizationLevel to test while running with optimizations --- Lib/test/test_zipimport.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py index 14318bf1e811bb..84995be3295682 100644 --- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -656,6 +656,8 @@ def test(val): self.assertEqual(mod.test(1), 1) if __debug__: self.assertRaises(AssertionError, mod.test, False) + else: + self.assertEqual(mod.test(0), 0) def testImport_WithStuff(self): # try importing from a zipfile which contains additional