GitHub user sarahwalters opened a pull request: https://github.com/apache/beam/pull/3878
[BEAM-2970] Add contains_in_any_order matcher Follow this checklist to help us incorporate your contribution quickly and easily: - [X] Make sure there is a [JIRA issue](https://issues.apache.org/jira/projects/BEAM/issues/) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [X] Each commit in the pull request should have a meaningful subject line and body. - [X] Format the pull request title like `[BEAM-XXX] Fixes bug in ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA issue. - [X] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [X] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). --- The Python testing utilities already provide an equal_to matcher, but the equal_to matcher assumes that the lists it's comparing contain objects which can be compared using < and ==. In particular, classes don't always define < and ==. contains_in_any_order is more general than equal_to: it doesn't rely on < and ==; instead, it takes as an argument a list of matcher functions, allowing the caller to provide its own definition of equality. You can merge this pull request into a Git repository by running: $ git pull https://github.com/sarahwalters/beam contains_in_any_order Alternatively you can review and apply these changes as the patch at: https://github.com/apache/beam/pull/3878.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #3878 ---- commit 295c936aaf247788a441a8b0575ee057588f35cb Author: Sarah Walters <sarahwalt...@google.com> Date: 2017-09-20T23:08:06Z Add a contains_in_any_order matcher. The testing utilities already provide an equal_to matcher, but the equal_to matcher assumes that the lists it's comparing contain objects which can be compared using < and ==. In particular, classes don't always define < and ==. contains_in_any_order is more general than equal_to -- it doesn't rely on < and ==; instead, it takes as an argument a list of matcher functions, allowing the caller to provide its own definition of equality. commit 44dd2c6e7b27113d4cfd47a0b502a4e0b6cb87af Author: Sarah Walters <sarahwalt...@google.com> Date: 2017-09-21T02:41:45Z Fix contains_in_any_order so it ignores order Now, contains_in_any_order performs a breadth-first search to find a mapping from items to predicates they satisfy. With this change, it becomes acceptable to specify predicates that match multiple items -> there's no danger of a predicate meant to match item i matching item j instead and being unavailable to match item i. ---- ---