]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45205: Make test_compileall quiet (GH-28356) (GH-28364)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 15 Sep 2021 19:33:52 +0000 (12:33 -0700)
committerGitHub <noreply@github.com>
Wed, 15 Sep 2021 19:33:52 +0000 (21:33 +0200)
Make test_compileall quiet: test_year_2038_mtime_compilation() and
test_larger_than_32_bit_times() of test_compileall no longer log
"Compiling ..." messages to stdout.
(cherry picked from commit cc057ff5227b3a4ded637caa7ba51b67b06abaaa)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/test/test_compileall.py

index a03735d3b76109563101c4b12c3efb40bf5d0123..6e1f4b2f397e28b9a8ee8715b5b17395580eb9ac 100644 (file)
@@ -86,7 +86,8 @@ class CompileallTestsBase:
             os.utime(self.source_path, (2**32 - 1, 2**32 - 1))
         except (OverflowError, OSError):
             self.skipTest("filesystem doesn't support timestamps near 2**32")
-        self.assertTrue(compileall.compile_file(self.source_path))
+        with contextlib.redirect_stdout(io.StringIO()):
+            self.assertTrue(compileall.compile_file(self.source_path))
 
     def test_larger_than_32_bit_times(self):
         # This is similar to the test above but we skip it if the OS doesn't
@@ -95,7 +96,8 @@ class CompileallTestsBase:
             os.utime(self.source_path, (2**35, 2**35))
         except (OverflowError, OSError):
             self.skipTest("filesystem doesn't support large timestamps")
-        self.assertTrue(compileall.compile_file(self.source_path))
+        with contextlib.redirect_stdout(io.StringIO()):
+            self.assertTrue(compileall.compile_file(self.source_path))
 
     def recreation_check(self, metadata):
         """Check that compileall recreates bytecode when the new metadata is