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 stefanheimann
Recipients
Date 2002-07-30.22:29:37
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
These two methods of the class TestCase are not very good:

    def failUnlessEqual(self, first, second, msg=None):
        """Fail if the two objects are unequal as
determined by the '!='
           operator.
        """
        if first != second:
            raise self.failureException, \
                  (msg or '%s != %s' % (`first`, `second`))

    def failIfEqual(self, first, second, msg=None):
        """Fail if the two objects are equal as
determined by the '=='
           operator.
        """
        if first == second:
            raise self.failureException, \
                  (msg or '%s == %s' % (`first`, `second`))

The first thing is that you should print the difference
of the given values like that:

'<%s> == <%s>' % (`first`, `second`)

The < and > delimits the string and so is is easier to
detect where the string starts and where it ends.

The second thing is that I would really like to see the
two values that are (not) equal even if I provide a
message. Maybe its better to raise the exception like that:

        if msg is not None:
            msg += ' Expected: <%s>, is: <%s>' %
(first, second)
        raise self.failureException, \
                  (msg or '%s != %s' % (`first`, `second`))

bye Stefan
History
Date User Action Args
2007-08-23 16:05:39adminlinkissue588825 messages
2007-08-23 16:05:39admincreate