mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
Closes #17730: in code.interact(), when banner="", do not print anything.
Also adds tests for banner printing.
This commit is contained in:
parent
a8fc7f6fac
commit
fbc3c3c2be
3 changed files with 19 additions and 2 deletions
|
|
@ -64,6 +64,20 @@ class TestInteractiveConsole(unittest.TestCase):
|
|||
self.console.interact()
|
||||
self.assertTrue(hook.called)
|
||||
|
||||
def test_banner(self):
|
||||
# with banner
|
||||
self.infunc.side_effect = EOFError('Finished')
|
||||
self.console.interact(banner='Foo')
|
||||
self.assertEqual(len(self.stderr.method_calls), 2)
|
||||
banner_call = self.stderr.method_calls[0]
|
||||
self.assertEqual(banner_call, ['write', ('Foo\n',), {}])
|
||||
|
||||
# no banner
|
||||
self.stderr.reset_mock()
|
||||
self.infunc.side_effect = EOFError('Finished')
|
||||
self.console.interact(banner='')
|
||||
self.assertEqual(len(self.stderr.method_calls), 1)
|
||||
|
||||
|
||||
def test_main():
|
||||
support.run_unittest(TestInteractiveConsole)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue