[Python-Dev] Need help fixing failing Py3k Unittests in py3k-struni

Steven Bethard steven.bethard at gmail.com
Wed Jul 11 00:38:53 CEST 2007


On 7/10/07, Christian Heimes <lists at cheimes.de> wrote:
> Guido van Rossum wrote:
> > Please help!
>
> I've made a meta patch that makes debugging the bugs a lot easier. It
> replaces assert_(foo == bar) and failUnless(foo == bar) with
> failUnlessEqual(foo, bar). failUnlessEqual shows the value of foo and
> bar when they are not equal.
>
> http://www.python.org/sf/1751515
>
> sed -r "s/self\.assert_\((.*)\ ==/self.failUnlessEqual\(\1,/" -i *.py
> sed -r "s/self\.failUnless\((.*)\ ==/self.failUnlessEqual\(\1,/" -i *.py

Some of these look questionable, e.g.:

-        self.assert_(d == self.spamle or d == self.spambe)
+        self.failUnlessEqual(d == self.spamle or d, self.spambe)
...
-        self.assert_((a == 42) is False)
+        self.failUnlessEqual((a, 42) is False)

I'd probably go with something a little more restrictive, maybe:

    r'self.assert_\(\S+ == \S+\)'

Something like that ought to have fewer false positives.

STeVe
-- 
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
        --- Bucky Katt, Get Fuzzy


More information about the Python-Dev mailing list