bpo-31836: Test_code_module now passes with sys.ps1, ps2 set (#4070)

This commit is contained in:
Terry Jan Reedy 2017-10-27 21:45:19 -04:00 committed by GitHub
parent e86172d63a
commit 5a4bbcd479
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -28,16 +28,24 @@ class TestInteractiveConsole(unittest.TestCase):
self.sysmod = stack.enter_context(prepatch) self.sysmod = stack.enter_context(prepatch)
if sys.excepthook is sys.__excepthook__: if sys.excepthook is sys.__excepthook__:
self.sysmod.excepthook = self.sysmod.__excepthook__ self.sysmod.excepthook = self.sysmod.__excepthook__
del self.sysmod.ps1
del self.sysmod.ps2
def test_ps1(self): def test_ps1(self):
self.infunc.side_effect = EOFError('Finished') self.infunc.side_effect = EOFError('Finished')
self.console.interact() self.console.interact()
self.assertEqual(self.sysmod.ps1, '>>> ') self.assertEqual(self.sysmod.ps1, '>>> ')
self.sysmod.ps1 = 'custom1> '
self.console.interact()
self.assertEqual(self.sysmod.ps1, 'custom1> ')
def test_ps2(self): def test_ps2(self):
self.infunc.side_effect = EOFError('Finished') self.infunc.side_effect = EOFError('Finished')
self.console.interact() self.console.interact()
self.assertEqual(self.sysmod.ps2, '... ') self.assertEqual(self.sysmod.ps2, '... ')
self.sysmod.ps1 = 'custom2> '
self.console.interact()
self.assertEqual(self.sysmod.ps1, 'custom2> ')
def test_console_stderr(self): def test_console_stderr(self):
self.infunc.side_effect = ["'antioch'", "", EOFError('Finished')] self.infunc.side_effect = ["'antioch'", "", EOFError('Finished')]

View File

@ -0,0 +1,4 @@
Test_code_module now passes if run after test_idle, which sets ps1.
The code module uses sys.ps1 if present or sets it to '>>> ' if not.
Test_code_module now properly tests both behaviors. Ditto for ps2.