Repository navigation
Closed
Description
| BPO | 31836 |
|---|---|
| Nosy | @terryjreedy, @serhiy-storchaka |
| PRs |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = 'https://github.com/terryjreedy'
closed_at = <Date 2017-10-28.11:44:06.434>
created_at = <Date 2017-10-21.16:03:19.215>
labels = ['3.7', 'tests', 'type-bug', 'library']
title = 'test_code_module fails after test_idle'
updated_at = <Date 2017-10-28.11:44:06.433>
user = 'https://github.com/serhiy-storchaka'bugs.python.org fields:
activity = <Date 2017-10-28.11:44:06.433>
actor = 'terry.reedy'
assignee = 'terry.reedy'
closed = True
closed_date = <Date 2017-10-28.11:44:06.434>
closer = 'terry.reedy'
components = ['Library (Lib)', 'Tests']
creation = <Date 2017-10-21.16:03:19.215>
creator = 'serhiy.storchaka'
dependencies = []
files = []
hgrepos = []
issue_num = 31836
keywords = ['patch']
message_count = 5.0
messages = ['304709', '304720', '304758', '305146', '305157']
nosy_count = 2.0
nosy_names = ['terry.reedy', 'serhiy.storchaka']
pr_nums = ['4070', '4156']
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue31836'
versions = ['Python 3.6', 'Python 3.7']
Activity
serhiy-storchaka commentedon Oct 21, 2017
$ ./python -m test -uall test_idle test_code_module Run tests sequentially 0:00:00 load avg: 0.42 [1/2] test_idle 0:00:02 load avg: 0.42 [2/2] test_code_module test test_code_module failed -- Traceback (most recent call last): File "/home/serhiy/py/cpython/Lib/test/test_code_module.py", line 35, in test_ps1 self.assertEqual(self.sysmod.ps1, '>>> ') AssertionError: <MagicMock name='sys.ps1' id='140109331413008'> != '>>> 'test_code_module failed
1 test OK.
1 test failed:
test_code_module
Total duration: 2 sec
Tests result: FAILURE
terryjreedy commentedon Oct 21, 2017
Running test_code_module afte test_idle, which somewhere executes idle code that sets sys.ps1, exposed a deficiency in test_code_module.
TestInteractiveConsole.test_ps1 is intended to test this code in InteractiveConsole.interact.
The existing test only tried to test the except branch, but without insuring that the AttributeError occurs. PR 4070 fixes that and adds a test of the try branch, that sys.ps1 is respected and left alone (and later used as it) when present. Ditto for test_ps2.
terryjreedy commentedon Oct 22, 2017
On the PR, Serhiy asks "Wouldn't be better to restore sys.ps1 in test_idle if it is changed here?"
Aside from the fact that, as far as I know, it is not sanely possible to do so, I think it a bug for a test to be unnecessarily fragile. Both ps1 and ps2 are set when Python is in interactive mode. IDLE is only (partially) imitating Python's shell when it sets sys.ps1.
terryjreedy commentedon Oct 28, 2017
New changeset 5a4bbcd by Terry Jan Reedy in branch 'master':
bpo-31836: Test_code_module now passes with sys.ps1, ps2 set (bpo-4070)
5a4bbcd
terryjreedy commentedon Oct 28, 2017
New changeset 8ed5644 by Terry Jan Reedy (Miss Islington (bot)) in branch '3.6':
bpo-31836: Test_code_module now passes with sys.ps1, ps2 set (GH-4070) (bpo-4156)
8ed5644