diff options
Diffstat (limited to 'lib/testtools/testtools/tests/matchers/test_higherorder.py')
-rw-r--r-- | lib/testtools/testtools/tests/matchers/test_higherorder.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/testtools/testtools/tests/matchers/test_higherorder.py b/lib/testtools/testtools/tests/matchers/test_higherorder.py index 61f59824a1..c5cc44eb1d 100644 --- a/lib/testtools/testtools/tests/matchers/test_higherorder.py +++ b/lib/testtools/testtools/tests/matchers/test_higherorder.py @@ -14,6 +14,7 @@ from testtools.matchers._higherorder import ( AllMatch, Annotate, AnnotatedMismatch, + AnyMatch, MatchesAny, MatchesAll, MatchesPredicate, @@ -50,6 +51,38 @@ class TestAllMatch(TestCase, TestMatchersInterface): ] +class TestAnyMatch(TestCase, TestMatchersInterface): + + matches_matcher = AnyMatch(Equals('elephant')) + matches_matches = [ + ['grass', 'cow', 'steak', 'milk', 'elephant'], + (13, 'elephant'), + ['elephant', 'elephant', 'elephant'], + set(['hippo', 'rhino', 'elephant']), + ] + matches_mismatches = [ + [], + ['grass', 'cow', 'steak', 'milk'], + (13, 12, 10), + ['element', 'hephalump', 'pachyderm'], + set(['hippo', 'rhino', 'diplodocus']), + ] + + str_examples = [ + ("AnyMatch(Equals('elephant'))", AnyMatch(Equals('elephant'))), + ] + + describe_examples = [ + ('Differences: [\n' + '7 != 11\n' + '7 != 9\n' + '7 != 10\n' + ']', + [11, 9, 10], + AnyMatch(Equals(7))), + ] + + class TestAfterPreprocessing(TestCase, TestMatchersInterface): def parity(x): |