From 2e33ecd7c9b0cac3efc6fcbdd4547fd086b4e2d1 Mon Sep 17 00:00:00 2001 From: Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com> Date: Tue, 28 May 2019 13:29:04 -0300 Subject: bpo-22640: Add silent mode to py_compile.compile() (GH-12976) --- Lib/test/test_py_compile.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Lib/test') diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py index f86abe26f9..d6677ab45f 100644 --- a/Lib/test/test_py_compile.py +++ b/Lib/test/test_py_compile.py @@ -192,6 +192,15 @@ class PyCompileTestsBase: fp.read(), 'test', {}) self.assertEqual(flags, 0b1) + def test_quiet(self): + bad_coding = os.path.join(os.path.dirname(__file__), 'bad_coding2.py') + with support.captured_stderr() as stderr: + self.assertIsNone(py_compile.compile(bad_coding, doraise=False, quiet=2)) + self.assertIsNone(py_compile.compile(bad_coding, doraise=True, quiet=2)) + self.assertEqual(stderr.getvalue(), '') + with self.assertRaises(py_compile.PyCompileError): + py_compile.compile(bad_coding, doraise=True, quiet=1) + class PyCompileTestsWithSourceEpoch(PyCompileTestsBase, unittest.TestCase, -- cgit v1.2.1