[Python-checkins] gh-92886: Fix tests that fail when running with optimizations (`-O`) in `test_zipimport.py` (GH-93236)

brettcannon webhook-mailer at python.org
Fri Jun 10 18:57:08 EDT 2022


https://github.com/python/cpython/commit/484a2357c8385694a077cf2ce0517f327fb0b172
commit: 484a2357c8385694a077cf2ce0517f327fb0b172
branch: main
author: jackh-ncl <1750152+jackh-ncl at users.noreply.github.com>
committer: brettcannon <brett at python.org>
date: 2022-06-10T15:57:04-07:00
summary:

gh-92886: Fix tests that fail when running with optimizations (`-O`) in `test_zipimport.py` (GH-93236)

files:
A Misc/NEWS.d/next/Tests/2022-05-25-23-00-35.gh-issue-92886.Y-vrWj.rst
M Lib/test/test_zipimport.py

diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py
index 66789262dd6ca..84995be329568 100644
--- a/Lib/test/test_zipimport.py
+++ b/Lib/test/test_zipimport.py
@@ -654,7 +654,10 @@ 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)
+        else:
+            self.assertEqual(mod.test(0), 0)
 
     def testImport_WithStuff(self):
         # try importing from a zipfile which contains additional
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 0000000000000..93c1ffe33f28a
--- /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``



More information about the Python-checkins mailing list