8000 Fix test_py_compile with -O mode (GH-115345) · python/cpython@07ef9d8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 07ef9d8

Browse files
Fix test_py_compile with -O mode (GH-115345)
1 parent 7b25a82 commit 07ef9d8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/test/test_py_compile.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ class PyCompileCLITestCase(unittest.TestCase):
227227
def setUp(self):
8000
228228
self.directory = tempfile.mkdtemp()
229229
self.source_path = os.path.join(self.directory, '_test.py')
230-
self.cache_path = importlib.util.cache_from_source(self.source_path)
230+
self.cache_path = importlib.util.cache_from_source(self.source_path,
231+
optimization='' if __debug__ else 1)
231232
with open(self.source_path, 'w') as file:
232233
file.write('x = 123\n')
233234

@@ -250,6 +251,7 @@ def pycompilecmd_failure(self, *args):
250251
return script_helper.assert_python_failure('-m', 'py_compile', *args)
251252

252253
def test_stdin(self):
254+
self.assertFalse(os.path.exists(self.cache_path))
253255
result = self.pycompilecmd('-', input=self.source_path)
254256
self.assertEqual(result.returncode, 0)
255257
self.assertEqual(result.stdout, b'')

0 commit comments

Comments
 (0)
0