Message92977
| 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:08 | tuben | set | recipients:
+ tuben |
| 2009年09月22日 09:28:07 | tuben | set | messageid: <1253611687.96.0.247846871836.issue6966@psf.upfronthosting.co.za> |
| 2009年09月22日 09:28:06 | tuben | link | issue6966 messages |
| 2009年09月22日 09:28:06 | tuben | create |
|