New submission from Jeff Tratner: One of the examples for assertRaisesRegex(p) is wrong by one character.
Current is: self.assertRaisesRegexp(ValueError, 'invalid literal for.*XYZ$', int, 'XYZ') The $ at the end is wrong because the actual error message is "ValueError: invalid literal for int() with base 10: 'XYZ'" (with a ``'`` at the end). Two options for fixing. Option 1 - remove $ self.assertRaisesRegexp(ValueError, 'invalid literal for.*XYZ', int, 'XYZ') Option 2 - add ' self.assertRaisesRegexp(ValueError, 'invalid literal for.*XYZ\'$', int, 'XYZ') Same example is shown for assertRaisesRegex, so applies to both. And for completeness...here's something you can run to see the error [couldn't figure out how to attach two files]: import unittest class MyTest(unittest.TestCase): def test_example(self): # this fails self.assertRaisesRegexp(ValueError, 'invalid literal for.*XYZ$', int, 'XYZ') def test_option1(self): self.assertRaisesRegexp(ValueError, 'invalid literal for.*XYZ', int, 'XYZ') def test_option2(self): self.assertRaisesRegexp(ValueError, 'invalid literal for.*XYZ\'$', int, 'XYZ') unittest.main() ---------- assignee: docs@python components: Documentation files: unittest.patch keywords: patch messages: 191306 nosy: docs@python, jtratner priority: normal severity: normal status: open title: unittest.assertRaisesRegex(p) example is wrong in docs versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5 Added file: http://bugs.python.org/file30615/unittest.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18237> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com