https://github.com/python/cpython/commit/55b9633316764923472d031c6aa5876c43aa6b94
commit: 55b9633316764923472d031c6aa5876c43aa6b94
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2024-02-19T17:45:56Z
summary:

[3.11] Fix test_py_compile with -O mode (GH-115345) (GH-115670)

(cherry picked from commit 07ef9d86a5efa82d06a8e7e15dd3aff1e946aa6b)

Co-authored-by: Serhiy Storchaka <[email protected]>

files:
M Lib/test/test_py_compile.py

diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py
index 6a54d48eb16e93..741df6b6bfc51f 100644
--- a/Lib/test/test_py_compile.py
+++ b/Lib/test/test_py_compile.py
@@ -227,7 +227,8 @@ class PyCompileCLITestCase(unittest.TestCase):
     def setUp(self):
         self.directory = tempfile.mkdtemp()
         self.source_path = os.path.join(self.directory, '_test.py')
-        self.cache_path = importlib.util.cache_from_source(self.source_path)
+        self.cache_path = importlib.util.cache_from_source(self.source_path,
+                                optimization='' if __debug__ else 1)
         with open(self.source_path, 'w') as file:
             file.write('x = 123\n')
 
@@ -249,6 +250,7 @@ def pycompilecmd_failure(self, *args):
         return script_helper.assert_python_failure('-m', 'py_compile', *args)
 
     def test_stdin(self):
+        self.assertFalse(os.path.exists(self.cache_path))
         result = self.pycompilecmd('-', input=self.source_path)
         self.assertEqual(result.returncode, 0)
         self.assertEqual(result.stdout, b'')

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to