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 tuben
Recipients tuben
Date 2009-09-22.09:28:06
SpamBayes Score 8.6999696e-10
Marked as misclassified No
Message-id <1253611687.96.0.247846871836.issue6966@psf.upfronthosting.co.za>
In-reply-to
Content
In the unittest module, TestCase class:

If one wants to provide a more descriptive fail message compared to the
default, it is often valuable to be able to refer to the arguments
evaluated by the fail*- (or assert*-) method. This can be accomplished
by binding names to the evaluated values before the call to the
fail*-methods, and then providing a string with the values embedded as
needed. This, however, can be quite cumbersome when there are a lot of
calls to fail*-methods.

Today:
Arg1 = RealValue()
Arg2 = ExpectedValue()
self.failUnlessEqual(Arg1, Arg2, "Got {0}, but expected
{1}.".format(Arg1, Arg2))

Proposed solution:
In the fail*-methods, check if the msg argument is some kind of string
(basestring?), and run the format() method on the string with the
supplied arguments. This would result in code like this:

self.failUnlessEqual(RealValue(), ExpectedValue(), "Got {0}, but
expected {1}.")
History
Date User Action Args
2009-09-22 09:28:08tubensetrecipients: + tuben
2009-09-22 09:28:07tubensetmessageid: <1253611687.96.0.247846871836.issue6966@psf.upfronthosting.co.za>
2009-09-22 09:28:06tubenlinkissue6966 messages
2009-09-22 09:28:06tubencreate