Issue 25109: test_code_module tests fail when run from the installed location (original) (raw)
seen when running the tests in the installed location:
the test expects:
Traceback (most recent call last): File "", line 1, in 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 "", line 1, in 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 "", line 1, in \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 "", line 1, in \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 "", line 1, in \nNameError: name 'ham' is not defined\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "", line 2, in \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 "", line 1, in \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 "", line 2, in \nNameError: name 'eggs' is not defined\n\n'
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.