summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_py_compile.py
diff options
context:
space:
mode:
authorJack Hindmarch <1750152+jackh-ncl@users.noreply.github.com>2022-10-19 10:05:08 (GMT)
committerGitHub <noreply@github.com>2022-10-19 10:05:08 (GMT)
commit602ea40d8936812367db2ffed5226ca25a607f46 (patch)
treef56fd83464970308ebe07c4c59deee0a14c9f0c3 /Lib/test/test_py_compile.py
parent9be05df3997de3fe9d34525871baa375cbccd7fc (diff)
downloadcpython-602ea40d8936812367db2ffed5226ca25a607f46.zip
cpython-602ea40d8936812367db2ffed5226ca25a607f46.tar.gz
cpython-602ea40d8936812367db2ffed5226ca25a607f46.tar.bz2
gh-92886: Fix tests that fail when running with optimizations (`-O`) in `test_py_compile.py` (GH-93235)
Diffstat (limited to 'Lib/test/test_py_compile.py')
-rw-r--r--Lib/test/test_py_compile.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py
index a4a52b1..5e0a44a 100644
--- a/Lib/test/test_py_compile.py
+++ b/Lib/test/test_py_compile.py
@@ -235,11 +235,12 @@ class PyCompileCLITestCase(unittest.TestCase):
# assert_python_* helpers don't return proc object. We'll just use
# subprocess.run() instead of spawn_python() and its friends to test
# stdin support of the CLI.
+ opts = '-m' if __debug__ else '-Om'
if args and args[0] == '-' and 'input' in kwargs:
- return subprocess.run([sys.executable, '-m', 'py_compile', '-'],
+ return subprocess.run([sys.executable, opts, 'py_compile', '-'],
input=kwargs['input'].encode(),
capture_output=True)
- return script_helper.assert_python_ok('-m', 'py_compile', *args, **kwargs)
+ return script_helper.assert_python_ok(opts, 'py_compile', *args, **kwargs)
def pycompilecmd_failure(self, *args):
return script_helper.assert_python_failure('-m', 'py_compile', *args)