self._defaults = {}
# determines whether an "option" looks like a negative number
- self._negative_number_matcher = _re.compile(r'^-\d[\d_]*(\.\d[\d_]*)?$')
+ self._negative_number_matcher = _re.compile(r'^-(?:\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?|\.\d+(?:_\d+)*)$')
# whether or not there are any optionals that look like negative
# numbers -- uses a list so it can be shared and edited
('--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)),
+ ('--float -.5', NS(int=None, float=-0.5)),
+ ('--float -.5_000', NS(int=None, float=-0.5)),
]
class TestInvalidAction(TestCase):