mirror of https://github.com/python/cpython.git
gh-92886: Fix tests that fail when running with optimizations (`-O`) in `test_py_compile.py` (GH-93235)
This commit is contained in:
parent
9be05df399
commit
602ea40d89
|
@ -235,11 +235,12 @@ def pycompilecmd(self, *args, **kwargs):
|
||||||
# assert_python_* helpers don't return proc object. We'll just use
|
# assert_python_* helpers don't return proc object. We'll just use
|
||||||
# subprocess.run() instead of spawn_python() and its friends to test
|
# subprocess.run() instead of spawn_python() and its friends to test
|
||||||
# stdin support of the CLI.
|
# stdin support of the CLI.
|
||||||
|
opts = '-m' if __debug__ else '-Om'
|
||||||
if args and args[0] == '-' and 'input' in kwargs:
|
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(),
|
input=kwargs['input'].encode(),
|
||||||
capture_output=True)
|
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):
|
def pycompilecmd_failure(self, *args):
|
||||||
return script_helper.assert_python_failure('-m', 'py_compile', *args)
|
return script_helper.assert_python_failure('-m', 'py_compile', *args)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fixing tests that fail when running with optimizations (``-O``) in ``test_py_compile.py``
|
Loading…
Reference in New Issue