From 892155d7365c9c4a6c2dd6850b4527222ba5c217 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Mon, 15 Jan 2024 13:21:34 +0300 Subject: gh-114075: Capture `test_compileall` stdout output (#114076) Co-authored-by: Alex Waygood --- Lib/test/test_compileall.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py index 83a9532..0ec6013 100644 --- a/Lib/test/test_compileall.py +++ b/Lib/test/test_compileall.py @@ -369,7 +369,9 @@ class CompileallTestsBase: script = script_helper.make_script(path, "test", "1 / 0") bc = importlib.util.cache_from_source(script) stripdir = os.path.join(self.directory, *(fullpath[:2] + ['fake'])) - compileall.compile_dir(path, quiet=True, stripdir=stripdir) + with support.captured_stdout() as out: + compileall.compile_dir(path, quiet=True, stripdir=stripdir) + self.assertIn("not a valid prefix", out.getvalue()) rc, out, err = script_helper.assert_python_failure(bc) expected_not_in = os.path.join(self.directory, *fullpath[2:]) self.assertIn( -- cgit v0.12