10000 bpo-31836: Test_code_module now passes with sys.ps1, ps2 set by terryjreedy · Pull Request #4070 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 28, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bpo-31836: Make test_code_module pass after test_idle.
Test_code_module assume sys.ps1 is initially absent; make it so.
Add test that code.interact respects existing sys.ps1. Ditto for ps2.
  • Loading branch information
terryjreedy committed Oct 21, 2017
commit 028f9977e8506b497eb18e8b7da12fa2be5ab5e8
13 changes: 13 additions & 0 deletions Lib/test/test_code_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@

class TestInteractiveConsole(unittest.TestCase):

@classmethod
def setUpClass(cls):
if hasattr(sys, 'ps1'): # If run after test_idle: see #31836.
del sys.ps1
if hasattr(sys, 'ps2'): # Just in case.
del sys.ps2

def setUp(self):
self.console = code.InteractiveConsole()
self.mock_sys()
Expand All @@ -33,11 +40,17 @@ def test_ps1(self):
self.infunc.side_effect = EOFError('Finished')
self.console.interact()
self.assertEqual(self.sysmod.ps1, '>>> ')
self.sysmod.ps1 = 'custom1> '
self.console.interact()
self.assertEqual(self.sysmod.ps1, 'custom1> ')

def test_ps2(self):
self.infunc.side_effect = EOFError('Finished')
self.console.interact()
self.assertEqual(self.sysmod.ps2, '... ')
self.sysmod.ps1 = 'custom2> '
self.console.interact()
self.assertEqual(self.sysmod.ps1, 'custom2> ')

def test_console_stderr(self):
self.infunc.side_effect = ["'antioch'", "", EOFError('Finished')]
Expand Down
0