Merge lp:~lifeless/testtools/haslength into lp:~testtools-committers/testtools/trunk
Proposed by
Robert Collins
Status: | Merged |
---|---|
Merged at revision: | 312 |
Proposed branch: | lp:~lifeless/testtools/haslength |
Merge into: | lp:~testtools-committers/testtools/trunk |
Diff against target: |
305 lines (+178/-1) 7 files modified
NEWS (+6/-0) doc/for-test-authors.rst (+37/-0) testtools/matchers/__init__.py (+4/-0) testtools/matchers/_basic.py (+12/-1) testtools/matchers/_higherorder.py (+76/-0) testtools/tests/matchers/test_basic.py (+16/-0) testtools/tests/matchers/test_higherorder.py (+27/-0) |
To merge this branch: | bzr merge lp:~lifeless/testtools/haslength |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Vincent Ladeuil | Approve | ||
testtools committers | Pending | ||
Review via email: mp+144578@code.launchpad.net |
Description of the change
I keep wanting a HasLength. And MatchesWithPred
To post a comment you must log in.
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 ?