bpo-22640: Add silent mode to py_compile.compile() (GH-12976)

This commit is contained in:
Joannah Nanjekye 2019-05-28 13:29:04 -03:00 committed by Berker Peksag
parent 3c8724fc60
commit 2e33ecd7c9
5 changed files with 43 additions and 9 deletions

View file

@ -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,