Feature Requests item #588825, was opened at 2002-07-30 17:29
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=588825&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Stefan Wehr (stefanheimann)
Assigned to: Collin Winter (collinwinter)
Summary: unittest.py, better error message

Initial Comment:
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

----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2007-03-30 11:52

Message:
Logged In: YES 
user_id=80475
Originator: NO

Collin, you should probably solicit Steve Purcell's input before
proceeding with the one.  The request seems reasonable but the module
author should have some say in the matter.

----------------------------------------------------------------------

Comment By: Brett Cannon (bcannon)
Date: 2003-05-20 23:47

Message:
Logged In: YES 
user_id=357491

I am making this an RFE since it is just a suggestion and not a bug.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2002-08-18 17:19

Message:
Logged In: YES 
user_id=80475

Steve, would you like these implemented or left as is?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=588825&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to