Message404891
I confirm this happens on all recent Python versions.
The source of this problem is that `argparse` uses `regex` module to replace some substrings. Direct link: https://github.com/python/cpython/blame/8ce20bbdd6d2b1277a5e74154fcdcef2cb0fee49/Lib/argparse.py#L487
Quick debug showed that without this line these tests fail:
```
======================================================================
FAIL: test_help_when_required (test.test_argparse.TestMutuallyExclusiveFirstSuppressed)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/sobolev/Desktop/cpython/Lib/test/test_argparse.py", line 2649, in test_help_when_required
self.assertEqual(format_help(), textwrap.dedent(help))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'usage: PROG [-h] (-y)\n\noptions:\n -h, --help show this[42 chars]lp\n' != 'usage: PROG [-h] -y\n\noptions:\n -h, --help show this h[40 chars]lp\n'
- usage: PROG [-h] (-y)
? - -
+ usage: PROG [-h] -y
options:
-h, --help show this help message and exit
-y y help
======================================================================
FAIL: test_usage_when_required (test.test_argparse.TestMutuallyExclusiveFirstSuppressed)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/sobolev/Desktop/cpython/Lib/test/test_argparse.py", line 2639, in test_usage_when_required
self.assertEqual(format_usage(), textwrap.dedent(expected_usage))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'usage: PROG [-h] (-y)\n' != 'usage: PROG [-h] -y\n'
- usage: PROG [-h] (-y)
? - -
+ usage: PROG [-h] -y
======================================================================
FAIL: test_help_when_required (test.test_argparse.TestMutuallyExclusiveFirstSuppressedParent)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/sobolev/Desktop/cpython/Lib/test/test_argparse.py", line 2649, in test_help_when_required
self.assertEqual(format_help(), textwrap.dedent(help))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'usage: PROG [-h] (-y)\n\noptions:\n -h, --help show this[42 chars]lp\n' != 'usage: PROG [-h] -y\n\noptions:\n -h, --help show this h[40 chars]lp\n'
- usage: PROG [-h] (-y)
? - -
+ usage: PROG [-h] -y
options:
-h, --help show this help message and exit
-y y help
======================================================================
FAIL: test_usage_when_required (test.test_argparse.TestMutuallyExclusiveFirstSuppressedParent)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/sobolev/Desktop/cpython/Lib/test/test_argparse.py", line 2639, in test_usage_when_required
self.assertEqual(format_usage(), textwrap.dedent(expected_usage))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'usage: PROG [-h] (-y)\n' != 'usage: PROG [-h] -y\n'
- usage: PROG [-h] (-y)
? - -
+ usage: PROG [-h] -y
----------------------------------------------------------------------
Ran 1672 tests in 23.258s
FAILED (failures=4)
test test_argparse failed
test_argparse failed (4 failures)
== Tests result: FAILURE ==
1 test failed:
test_argparse
Total duration: 25.6 sec
Tests result: FAILURE
``` |
|
Date |
User |
Action |
Args |
2021-10-23 16:11:02 | sobolevn | set | recipients:
+ sobolevn, lys.nikolaou, pablogsal, AbcSxyZ |
2021-10-23 16:11:02 | sobolevn | set | messageid: <1635005462.66.0.566649016847.issue45580@roundup.psfhosted.org> |
2021-10-23 16:11:02 | sobolevn | link | issue45580 messages |
2021-10-23 16:11:02 | sobolevn | create | |
|