From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sat, 18 Jul 2026 15:34:41 +0000 (+0200) Subject: [3.14] Add test coverage to check execution of GetoptError.__str__ (GH-153941) (... X-Git-Url: http://git.ipfire.org/index.cgi?a=commitdiff_plain;h=02a91ea88cbba8d547b01ee308e4f9d2fbb3091f;p=thirdparty%2FPython%2Fcpython.git [3.14] Add test coverage to check execution of GetoptError.__str__ (GH-153941) (#153998) 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 --- diff --git a/Lib/test/test_getopt.py b/Lib/test/test_getopt.py index 8d0d5084abbb..961efc86fc26 100644 --- a/Lib/test/test_getopt.py +++ b/Lib/test/test_getopt.py @@ -198,6 +198,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