mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
GH-123945: Update regex for parsing negative numbers that contain underscores (#123970)
--------- Co-authored-by: Brandt Bucher <brandtbucher@gmail.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
parent
0a32c6959c
commit
14e5bdceff
3 changed files with 22 additions and 1 deletions
|
@ -2093,6 +2093,26 @@ class TestActionExtend(ParserTestCase):
|
|||
]
|
||||
|
||||
|
||||
class TestNegativeNumber(ParserTestCase):
|
||||
"""Test parsing negative numbers"""
|
||||
|
||||
argument_signatures = [
|
||||
Sig('--int', type=int),
|
||||
Sig('--float', type=float),
|
||||
]
|
||||
failures = [
|
||||
'--float -_.45',
|
||||
'--float -1__000.0',
|
||||
'--int -1__000',
|
||||
]
|
||||
successes = [
|
||||
('--int -1000 --float -1000.0', NS(int=-1000, float=-1000.0)),
|
||||
('--int -1_000 --float -1_000.0', NS(int=-1000, float=-1000.0)),
|
||||
('--int -1_000_000 --float -1_000_000.0', NS(int=-1000000, float=-1000000.0)),
|
||||
('--float -1_000.0', NS(int=None, float=-1000.0)),
|
||||
('--float -1_000_000.0_0', NS(int=None, float=-1000000.0)),
|
||||
]
|
||||
|
||||
class TestInvalidAction(TestCase):
|
||||
"""Test invalid user defined Action"""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue