]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add test coverage to check execution of GetoptError.__str__ (#153941)
authorManith Hettiarachchilage <manithhetti@gmail.com>
Sat, 18 Jul 2026 15:00:13 +0000 (16:00 +0100)
committerGitHub <noreply@github.com>
Sat, 18 Jul 2026 15:00:13 +0000 (15:00 +0000)
* Increase test coverage of getopt to check execution of GetoptError.__str__

* Add test coverage to check execution of GetoptError.__str__

* Add test coverage to check execution of GetoptError.__str__

* Add test coverage to check execution of GetoptError.__str__

* Add test coverage to check execution of GetoptError.__str__

* Add test coverage to check execution of GetoptError.__str__

Lib/test/test_getopt.py

index 8b6c3b8baa07c5e1ee930751639196ae99af618c..fac2ca3db81d703d459ed2d36db54fa5876b2fe8 100644 (file)
@@ -229,6 +229,10 @@ class GetoptTests(unittest.TestCase):
         self.assertEqual(longopts, [('--help', 'x')])
         self.assertRaises(getopt.GetoptError, getopt.getopt, ['--help='], '', ['help'])
 
+    def test_getopt_error_str(self):
+        error  = getopt.GetoptError('option -a not recognized', 'a')
+        self.assertEqual(str(error), 'option -a not recognized')
+
 def test_libref_examples():
     """
     Examples from the Library Reference:  Doc/lib/libgetopt.tex