Issue31836
Created on 2017-10-21 16:03 by serhiy.storchaka, last changed 2017-10-28 11:44 by terry.reedy. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 4070 | merged | terry.reedy, 2017-10-21 19:46 | |
| PR 4156 | merged | python-dev, 2017-10-28 01:45 | |
| Messages (5) | |||
|---|---|---|---|
| msg304709 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * | Date: 2017-10-21 16:03 | |
$ ./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 |
|||
| msg304720 - (view) | Author: Terry J. Reedy (terry.reedy) * | Date: 2017-10-21 20:06 | |
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.
try:
sys.ps1
except AttributeError:
sys.ps1 = ">>> "
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.
|
|||
| msg304758 - (view) | Author: Terry J. Reedy (terry.reedy) * | Date: 2017-10-22 18:25 | |
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. The premise of #25588 is that tests should accommodate sys.stdout and sys.stderr being None to the extent possible. I think the same applies to sys.ps1/2 being set. Indeed, as I reported on #31761, in msg304298, 9 days ago, test_code_module tests test_ps1 and test_ps2 failed when I ran '>>> import test.autotest' in a *Python* shell. I did not understand the reason for the failures then, but if I had investigated, I should hope that I would have submitted the same PR, which fixes this autotest failure. |
|||
| msg305146 - (view) | Author: Terry J. Reedy (terry.reedy) * | Date: 2017-10-28 01:45 | |
New changeset 5a4bbcd479ce86f68bbe12bc8c16e3447f32e13a by Terry Jan Reedy in branch 'master': bpo-31836: Test_code_module now passes with sys.ps1, ps2 set (#4070) https://github.com/python/cpython/commit/5a4bbcd479ce86f68bbe12bc8c16e3447f32e13a |
|||
| msg305157 - (view) | Author: Terry J. Reedy (terry.reedy) * | Date: 2017-10-28 11:43 | |
New changeset 8ed5644f78e57cd59813097b35906ad6f1775f95 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) (#4156) https://github.com/python/cpython/commit/8ed5644f78e57cd59813097b35906ad6f1775f95 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2017-10-28 11:44:06 | terry.reedy | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2017-10-28 11:43:20 | terry.reedy | set | messages: + msg305157 |
| 2017-10-28 01:45:28 | python-dev | set | stage: patch review pull_requests: + pull_request4126 |
| 2017-10-28 01:45:21 | terry.reedy | set | messages: + msg305146 |
| 2017-10-22 18:26:00 | terry.reedy | set | messages: + msg304758 |
| 2017-10-21 20:06:52 | terry.reedy | set | messages:
+ msg304720 components: + Library (Lib), - IDLE stage: patch review -> (no value) |
| 2017-10-21 19:46:20 | terry.reedy | set | keywords:
+ patch stage: patch review pull_requests: + pull_request4041 |
| 2017-10-21 16:03:19 | serhiy.storchaka | create | |