Merge lp:~rvb/testtools/testtools-contains-all into lp:~testtools-committers/testtools/trunk
Proposed by
Raphaël Badin
Status: | Merged |
---|---|
Merged at revision: | 261 |
Proposed branch: | lp:~rvb/testtools/testtools-contains-all |
Merge into: | lp:~testtools-committers/testtools/trunk |
Diff against target: |
72 lines (+29/-1) 2 files modified
testtools/matchers.py (+11/-0) testtools/tests/test_matchers.py (+18/-1) |
To merge this branch: | bzr merge lp:~rvb/testtools/testtools-contains-all |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jonathan Lange | Needs Fixing | ||
Review via email: mp+104065@code.launchpad.net |
Commit message
New matcher ContainsAll.
Description of the change
This branch adds a new (shortcut) matcher ContainsAll. ContainsAll(items) that can be used instead of using MatchesAll(
Drive-by fix: removed unused import.
To post a comment you must log in.
Thanks for the patch, Raphaël.
I don't quite understand the matcher though. From the docstring and the name, I would have guess something like this::
self. assertThat( [1, 2, 3], ContainsAll([3, 1]))
That is, self.assertThat(Y, ContainsAll(X)) would pass if and only if X is a subset of Y.
As it is, self.assertThat(Y, ContainsAll(X)) passes iff for all y in Y, for all x in X, x in y. (i.e. ∀ y ∊ Y, ∀ x ∊ X, 'x in y')
So, to me, the name is confusing and my lazy imagination isn't leaping to actual use cases.
Where to from here?
* Demonstrate use cases
* Pick a better name, maybe EachContainsAll
Follow up work for testtools more generally:
* some kind of more generic helper might be interesting, e.g. *[matcher( item) for item in items], first_only=False)
lambda matcher, items: MatchesAll(
I don't really know what it ought to be called. Sorry.
* MatchesAll is really an "And"-style function. It would probably be better if its name reflected that.
* More generally, thinking a little bit more about predicate & set algebra might provide us with some better combinators
Thanks,
jml