]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] Add test coverage to check execution of GetoptError.__str__ (GH-153941) (...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 18 Jul 2026 15:30:28 +0000 (17:30 +0200)
committerGitHub <noreply@github.com>
Sat, 18 Jul 2026 15:30:28 +0000 (15:30 +0000)
Add test coverage to check execution of GetoptError.__str__ (GH-153941)

* 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__
(cherry picked from commit 9adef68a7956744b804d09c8b8b06c8c171053e5)

Co-authored-by: Manith Hettiarachchilage <manithhetti@gmail.com>
Lib/test/test_getopt.py

index 295a2c81363e10fd478367f7ae3455052586cc6e..ceddd97772f825f29aa7d15cf3770cf1c28a3929 100644 (file)
@@ -141,6 +141,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