From: Manith Hettiarachchilage Date: Sat, 18 Jul 2026 15:00:13 +0000 (+0100) Subject: Add test coverage to check execution of GetoptError.__str__ (#153941) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9adef68a7956744b804d09c8b8b06c8c171053e5;p=thirdparty%2FPython%2Fcpython.git Add test coverage to check execution of GetoptError.__str__ (#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__ --- diff --git a/Lib/test/test_getopt.py b/Lib/test/test_getopt.py index 8b6c3b8baa07..fac2ca3db81d 100644 --- a/Lib/test/test_getopt.py +++ b/Lib/test/test_getopt.py @@ -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