This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_code_module tests fail when run from the installed location
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: doko, terry.reedy
Priority: normal Keywords:

Created on 2015-09-14 11:26 by doko, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg250655 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2015-09-14 11:26
seen when running the tests in the installed location:

the test expects:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
ValueError

but it gets:

Traceback (most recent call last):
  File "/usr/lib/python3.5/code.py", line 91, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
ValueError

same for the other failing test case.

Re-running test 'test_code_module' in verbose mode
test_banner (test.test_code_module.TestInteractiveConsole) ... ok
test_cause_tb (test.test_code_module.TestInteractiveConsole) ... FAIL
test_console_stderr (test.test_code_module.TestInteractiveConsole) ... ok
test_context_tb (test.test_code_module.TestInteractiveConsole) ... FAIL
test_ps1 (test.test_code_module.TestInteractiveConsole) ... ok
test_ps2 (test.test_code_module.TestInteractiveConsole) ... ok
test_syntax_error (test.test_code_module.TestInteractiveConsole) ... ok
test_sysexcepthook (test.test_code_module.TestInteractiveConsole) ... ok

======================================================================
FAIL: test_cause_tb (test.test_code_module.TestInteractiveConsole)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.5/test/test_code_module.py", line 96, in test_cause_tb
    self.assertIn(expected, output)
AssertionError: '\nAttributeError\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File "<console>", line 1, in <module>\nValueError\n' not found in 'Python <MagicMock name=\'sys.version\' id=\'139948544843304\'> on <MagicMock name=\'sys.platform\' id=\'139948544946784\'>\nType "help", "copyright", "credits" or "license" for more information.\n(InteractiveConsole)\nAttributeError\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File "/usr/lib/python3.5/code.py", line 91, in runcode\n    exec(code, self.locals)\n  File "<console>", line 1, in <module>\nValueError\n\n'

======================================================================
FAIL: test_context_tb (test.test_code_module.TestInteractiveConsole)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.5/test/test_code_module.py", line 114, in test_context_tb
    self.assertIn(expected, output)
AssertionError: '\nTraceback (most recent call last):\n  File "<console>", line 1, in <module>\nNameError: name \'ham\' is not defined\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File "<console>", line 2, in <module>\nNameError: name \'eggs\' is not defined\n' not found in 'Python <MagicMock name=\'sys.version\' id=\'139948132216360\'> on <MagicMock name=\'sys.platform\' id=\'139948132186544\'>\nType "help", "copyright", "credits" or "license" for more information.\n(InteractiveConsole)\nTraceback (most recent call last):\n  File "<console>", line 1, in <module>\nNameError: name \'ham\' is not defined\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File "/usr/lib/python3.5/code.py", line 91, in runcode\n    exec(code, self.locals)\n  File "<console>", line 2, in <module>\nNameError: name \'eggs\' is not defined\n\n'
msg251025 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-09-18 20:57
This is 3.5+ only as 2.7 does not have the module and 3.4 does not have the 2 test_xyz_tb functions that failed. This works OK on Win7.

C:\Users\Terry>python -m test -v test_code_module
== CPython 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)]
==   Windows-7-6.1.7601-SP1 little-endian
==   hash algorithm: siphash24 64bit
==   C:\Users\Terry\AppData\Local\Temp\test_python_4952
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_enviro
nment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0)
[1/1] test_code_module
test_banner (test.test_code_module.TestInteractiveConsole) ... ok
test_cause_tb (test.test_code_module.TestInteractiveConsole) ... ok
test_console_stderr (test.test_code_module.TestInteractiveConsole) ... ok
test_context_tb (test.test_code_module.TestInteractiveConsole) ... ok
test_ps1 (test.test_code_module.TestInteractiveConsole) ... ok
test_ps2 (test.test_code_module.TestInteractiveConsole) ... ok
test_syntax_error (test.test_code_module.TestInteractiveConsole) ... ok
test_sysexcepthook (test.test_code_module.TestInteractiveConsole) ... ok

What system did you use? (System dependence is odd, but there it is ;-)

The obvious fix is to reduce 'expected' to the common part, and at least for the second test, split into 2 assertIns.
msg316401 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2018-05-11 15:50
this seems to be fixed in 3.6 (3.6.5) and 3.7 (beta4).
History
Date User Action Args
2022-04-11 14:58:21adminsetgithub: 69296
2018-05-11 15:50:32dokosetstatus: open -> closed
resolution: fixed
messages: + msg316401

stage: needs patch -> resolved
2015-09-18 20:57:18terry.reedysetversions: + Python 3.6
nosy: + terry.reedy

messages: + msg251025

type: behavior
stage: needs patch
2015-09-14 11:27:30dokolinkissue17750 dependencies
2015-09-14 11:26:51dokocreate