From ed0c66c632fa145b3aa7345f062942181e2538ca Mon Sep 17 00:00:00 2001 From: Jack Hindmarch Date: Wed, 25 May 2022 23:51:32 +0100 Subject: [PATCH 1/2] Fixing tests that fail when running with optimizations (`-O`) in `test_py_compile.py` --- Lib/test/test_py_compile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py index 794d6436b61ab0..437ba113f482be 100644 --- a/Lib/test/test_py_compile.py +++ b/Lib/test/test_py_compile.py @@ -235,11 +235,12 @@ def pycompilecmd(self, *args, **kwargs): # 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) From f2e402de07e6e43987141a77236741cdbc0f802f Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 25 May 2022 22:53:31 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Tests/2022-05-25-22-53-30.gh-issue-92886.mIfdtz.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Tests/2022-05-25-22-53-30.gh-issue-92886.mIfdtz.rst diff --git a/Misc/NEWS.d/next/Tests/2022-05-25-22-53-30.gh-issue-92886.mIfdtz.rst b/Misc/NEWS.d/next/Tests/2022-05-25-22-53-30.gh-issue-92886.mIfdtz.rst new file mode 100644 index 00000000000000..014e9e614ccabc --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2022-05-25-22-53-30.gh-issue-92886.mIfdtz.rst @@ -0,0 +1 @@ +Fixing tests that fail when running with optimizations (``-O``) in ``test_py_compile.py``