This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jtratner
Recipients docs@python, jtratner
Date 2013-06-17.01:34:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1371432897.82.0.367432880569.issue18237@psf.upfronthosting.co.za>
In-reply-to
Content
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()
History
Date User Action Args
2013-06-17 01:34:57jtratnersetrecipients: + jtratner, docs@python
2013-06-17 01:34:57jtratnersetmessageid: <1371432897.82.0.367432880569.issue18237@psf.upfronthosting.co.za>
2013-06-17 01:34:57jtratnerlinkissue18237 messages
2013-06-17 01:34:57jtratnercreate