Skip to content

Commit e836a29

Browse files
committed
Add test coverage to check execution of GetoptError.__str__
1 parent 33d6d8c commit e836a29

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Lib/test/test_getopt.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ def assertError(self, *args, **kwargs):
2121
def assertErrorMessage(self, *args, message, **kwargs):
2222
self.assertRaisesRegex(getopt.GetoptError, message, *args, **kwargs)
2323

24+
def test_getopts_error_str(self):
25+
error = getopt.GetoptError('option -a not recognized', 'a')
26+
self.assertEqual(str(error), 'option -a not recognized')
27+
28+
2429
def test_short_has_arg(self):
2530
self.assertIs(getopt.short_has_arg('a', 'a:'), True)
2631
self.assertIs(getopt.short_has_arg('a', 'a'), False)
2732
self.assertEqual(getopt.short_has_arg('a', 'a::'), '?')
2833
self.assertError(getopt.short_has_arg, 'a', 'b')
29-
self.assertErrorMessage(
30-
getopt.short_has_arg, 'a', 'b', message='option -a not recognized'
31-
)
3234

3335
def test_long_has_args(self):
3436
has_arg, option = getopt.long_has_args('abc', ['abc='])

0 commit comments

Comments
 (0)