[TIP] Fwd: [Launchpad-dev] Reminder about a great Testtools matcher
mbp at sourcefrog.net
Tue Jul 19 19:31:42 PDT 2011
On 20 July 2011 11:37, Herman Sheremetyev <herman at swebpage.com> wrote:
> I hope not. I would hope to see more smaller tests rather than armies
> of asserts in a single test.
I don't think having separate tests that check the to_pocket is
correct and that the to_series is correct and the version is correct
would be desirable. There is one logical operation, and then we want
to check various aspects of the result.
> Yes, it's necessary to have multiple
> asserts per test at times, but in a case like the above where you're
> comparing properties on the same object, the fact that you're doing
> separate asserts should steer you toward writing a better equality
> operator on that object rather than bunching a ton of asserts into a
> single statement.
I agree it should steer you in that direction. On the other hand
sometimes you don't want to compare the whole object value, or you
don't want to support __eq__ on the class, or the class is not
sufficiently like a value object that you can make a new one to
The follow on to that post,
<https://lists.launchpad.net/launchpad-dev/msg07664.html> has a better
expression that avoids repeating the Equals every time.
I think it's a useful stepwise improvement. You could then later add
an overall matcher that compares this specific class.
More information about the testing-in-python