Issue 36014: test_help_with_metavar broken - Python tracker
Created on 2019-02-17 04:47 by wabba, last changed 2022-04-11 14:59 by admin. This issue is now closed.
Messages (7)
msg335748 - (view)
Author: wabba (wabba)
Date: 2019-02-17 04:47
Date: 2019-02-17 05:09
Date: 2019-02-17 05:30
The test_help_with_metavar test appears to be broken.
It fails with an assertion error:
AssertionError: 'usag[55 chars]_name [-h] [--proxy <http[s]://example:1234>]\[113 chars]4>\n' != 'usag[55 chars]_name\n [-h] [--proxy <http[s]://example[121 chars]4>\n'
If I change
"this_is_spammy_prog_with_a_long_name_sorry_about_the_name
[-h] [--proxy <http[s]://example:1234>]"
to
"this_is_spammy_prog_with_a_long_name_sorry_about_the_name [-h] [--proxy <http[s]://example:1234>]"
i.e. move the part starting with '[-h]' onto the same line, the test passes.
What is the correct output expected here? I would think the [-h] should be on the same line, but maybe this is intended behavior and the problem is with my system. No other unit test is failing for me though.
msg335750 - (view)
Author: Karthikeyan Singaravelan (xtreak) *
Date: 2019-02-17 05:09
Tests were added with 842985f6c70484ed7b8fc30d0bc05aec73236a98 and passes on master and 3.7.1 . Can you please add the full traceback and the command you used to run the test? Also the output of python version as below to try reproducing it python -m test.pythoninfo | grep 'sys.version:'msg335751 - (view) Author: wabba (wabba) Date: 2019-02-17 05:12
Output from running "python3 -m test.pythoninfo | grep 'sys.version:'": sys.version: 3.7.2 (default, Feb 17 2019, 11:51:43) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]msg335752 - (view) Author: wabba (wabba) Date: 2019-02-17 05:14
Btw, I am running 3.7.2 because that's the latest version offered on https://www.python.org/downloads/msg335753 - (view) Author: wabba (wabba) Date: 2019-02-17 05:18
Ah sorry, forgot the traceback and command: Command: python3 Lib/test/test_argparse.py test (__main__.TestActionRegistration) ... ok test_failures_many_groups_listargs (__main__.TestActionUserDefined) ... ok test_failures_many_groups_sysargs (__main__.TestActionUserDefined) ... ok ... ... ====================================================================== FAIL: test_help_with_metavar (__main__.TestWrappingMetavar) ---------------------------------------------------------------------- Traceback (most recent call last): File "Lib/test/test_argparse.py", line 5152, in test_help_with_metavar ''')) AssertionError: 'usag[55 chars]_name [-h] [--proxy <http[s]://example:1234>]\[113 chars]4>\n' != 'usag[55 chars]_name\n [-h] [--proxy <http[s]://example[121 chars]4>\n' - usage: this_is_spammy_prog_with_a_long_name_sorry_about_the_name [-h] [--proxy <http[s]://example:1234>] ? ---------------------------------------- + usage: this_is_spammy_prog_with_a_long_name_sorry_about_the_name + [-h] [--proxy <http[s]://example:1234>] optional arguments: -h, --help show this help message and exit --proxy <http[s]://example:1234> ---------------------------------------------------------------------- Ran 1574 tests in 4.558s FAILED (failures=1) Traceback (most recent call last): File "Lib/test/test_argparse.py", line 5164, in <module> test_main() File "Lib/test/test_argparse.py", line 5156, in test_main support.run_unittest(__name__) File "/usr/local/lib/python3.7/test/support/__init__.py", line 1991, in run_unittest _run_suite(suite) File "/usr/local/lib/python3.7/test/support/__init__.py", line 1910, in _run_suite raise TestFailed(err) test.support.TestFailed: Traceback (most recent call last): File "Lib/test/test_argparse.py", line 5152, in test_help_with_metavar ''')) AssertionError: 'usag[55 chars]_name [-h] [--proxy <http[s]://example:1234>]\[113 chars]4>\n' != 'usag[55 chars]_name\n [-h] [--proxy <http[s]://example[121 chars]4>\n' - usage: this_is_spammy_prog_with_a_long_name_sorry_about_the_name [-h] [--proxy <http[s]://example:1234>] ? ---------------------------------------- + usage: this_is_spammy_prog_with_a_long_name_sorry_about_the_name + [-h] [--proxy <http[s]://example:1234>] optional arguments: -h, --help show this help message and exit --proxy <http[s]://example:1234> I first encountered this error when running "make test" when installing python 3.7.2, then tried running this test manually with the command above.msg335754 - (view) Author: Karthikeyan Singaravelan (xtreak) *
Date: 2019-02-17 05:30
Thanks for the details. I couldn't reproduce this on a clean v3.7.2 build on Mac. There were also no changes to argparse.py between 3.7.0 and 3.7.2 so I don't know why it's failing on your environment. ➜ cpython git:(9a3ffc0492) git log v3.7.0..v3.7.2 Lib/argparse.py | cat ➜ cpython git:(9a3ffc0492) ./python.exe -m test.pythoninfo | grep 'sys.version:' sys.version: 3.7.2 (tags/v3.7.2:9a3ffc0492, Feb 17 2019, 10:47:33) [Clang 7.0.2 (clang-700.1.81)] ➜ cpython git:(9a3ffc0492) ./python.exe -m unittest -v test.test_argparse.TestWrappingMetavar.test_help_with_metavar test_help_with_metavar (test.test_argparse.TestWrappingMetavar) ... ok ---------------------------------------------------------------------- Ran 1 test in 0.004s OKmsg335757 - (view) Author: wabba (wabba) Date: 2019-02-17 06:50
Figured it out. My shell had the COLUMNS environment variable set, and python was inheriting it in os.environ. The failing test case assumes an 80-column screen. Anyway, looks like it has been fixed for 3.8 here: https://github.com/python/cpython/commit/74102c9a5f2327c4fc47feefa072854a53551d1f#diff-837b312b1f3508216ace6adb46492836 Closing this item.
History
Date
User
Action
Args
2022-04-11 14:59:11adminsetgithub: 80195
2019-02-18 18:14:10paul.j3setnosy:
+ paul.j3
2019-02-17 06:50:54wabbasetstatus: open -> closed
messages: + msg335750
2019-02-17 04:47:32wabbacreate
2019-02-17 06:50:54wabbasetstatus: open -> closed
messages:
+ msg335757
stage: resolved
messages: + msg335750
2019-02-17 04:47:32wabbacreate