Code review comment for lp:~lifeless/testtools/haslength

Revision history for this message
Vincent Ladeuil (vila) wrote :

Nice, I was searching for the moral equivalent of bzr's assertLength and couldn't find it last week ;)

25 +HasLength
26 +~~~~~~~~~
27 +
28 +Check the length of a collection. For example::
29 +
30 + self.assertThat([1, 2, 3], HasLength(2))

I can see this assertion will fail but stating so in the text would be
clearer IMHO. The other examples in this file I've looked at are of the
form: "Matches if <...>: <example>"

160 + HasLength = MatchesPredicate(
161 + lambda x, y: len(x) == y, 'len({0}) is not {1}')
162 + self.assertThat([1, 2], HasLength(3))

Same here ?

review: Approve

« Back to merge proposal