summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_code_module.py
diff options
context:
space:
mode:
authorSteven D'Aprano <steve@pearwood.info>2016-08-23 15:42:15 (GMT)
committerSteven D'Aprano <steve@pearwood.info>2016-08-23 15:42:15 (GMT)
commit6877ed3560aef64391657f634cbe00d16023201a (patch)
tree8509396753039f785fb8e07f9224b78871247357 /Lib/test/test_code_module.py
parentf4d28d43857295cab4dc82a2bc50f5e8c90123ef (diff)
downloadcpython-6877ed3560aef64391657f634cbe00d16023201a.zip
cpython-6877ed3560aef64391657f634cbe00d16023201a.tar.gz
cpython-6877ed3560aef64391657f634cbe00d16023201a.tar.bz2
Issue #27573 make the exit message configurable.
Diffstat (limited to 'Lib/test/test_code_module.py')
-rw-r--r--Lib/test/test_code_module.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_code_module.py b/Lib/test/test_code_module.py
index 08ba3f3..1a8f699 100644
--- a/Lib/test/test_code_module.py
+++ b/Lib/test/test_code_module.py
@@ -80,6 +80,7 @@ class TestInteractiveConsole(unittest.TestCase):
self.assertEqual(len(self.stderr.method_calls), 2)
def test_exit_msg(self):
+ # default exit message
self.infunc.side_effect = EOFError('Finished')
self.console.interact(banner='')
self.assertEqual(len(self.stderr.method_calls), 2)
@@ -87,6 +88,25 @@ class TestInteractiveConsole(unittest.TestCase):
expected = 'now exiting InteractiveConsole...\n'
self.assertEqual(err_msg, ['write', (expected,), {}])
+ # no exit message
+ self.stderr.reset_mock()
+ self.infunc.side_effect = EOFError('Finished')
+ self.console.interact(banner='', exitmsg='')
+ self.assertEqual(len(self.stderr.method_calls), 1)
+
+ # custom exit message
+ self.stderr.reset_mock()
+ message = (
+ 'bye! \N{GREEK SMALL LETTER ZETA}\N{CYRILLIC SMALL LETTER ZHE}'
+ )
+ self.infunc.side_effect = EOFError('Finished')
+ self.console.interact(banner='', exitmsg=message)
+ self.assertEqual(len(self.stderr.method_calls), 2)
+ err_msg = self.stderr.method_calls[1]
+ expected = message + '\n'
+ self.assertEqual(err_msg, ['write', (expected,), {}])
+
+
def test_cause_tb(self):
self.infunc.side_effect = ["raise ValueError('') from AttributeError",
EOFError('Finished')]