[Python-Dev] unittest assertRaisesRegex bug?

Antoine Pitrou solipsis at pitrou.net
Wed Mar 19 23:57:51 CET 2014


On Wed, 19 Mar 2014 15:17:53 -0700
Ethan Furman <ethan at stoneleaf.us> wrote:
> On 03/19/2014 03:13 PM, Antoine Pitrou wrote:
> > On Wed, 19 Mar 2014 14:37:42 -0700
> > Ethan Furman <ethan at stoneleaf.us> wrote:
> >> Here's the code in question:
> >>
> >>           class PsuedoFloat:
> >>               def __init__(self, value):
> >>                   self.value = float(value)
> >>               def __int__(self):
> >>                   return int(self.value)
> >>
> >>           pi = PsuedoFloat(3.1415)
> >>
> >>           self.assertRaisesRegex(TypeError, '%x format: an integer is required, not PsuedoFloat', '%x'.__mod__, pi),
> >>
> >> Here's the exception:
> >>
> >> ======================================================================
> >> ERROR: test_formatting (test.test_unicode.UnicodeTest)
> >> ----------------------------------------------------------------------
> >> TypeError: 'PsuedoFloat' object is not callable
> >>
> >> During handling of the above exception, another exception occurred:
> >>
> >> Traceback (most recent call last):
> >>     File "/home/ethan/source/python/issue19995/Lib/test/test_unicode.py", line 1156, in test_formatting
> >>       self.assertRaisesRegex(TypeError, '%c'.__mod__, pi),
> >
> > This is certainly not the code you are showing above.
> 
> More words, please!  :)

I mean the line shown just above in the traceback does not match the
code you presented at the top, and that line clearly has a missing
regex pattern.

Regards

Antoine.




More information about the Python-Dev mailing list