def testNoMatchIfArgumentFailsToSatisfyAnyOfManyOtherMatchers(self): self.assert_does_not_match( "all matchers", any_of( equal_to("bad"), equal_to("bad"), equal_to("bad"), equal_to("bad"), equal_to("bad") ), "good", )
def testMatchesIfArgumentSatisfiesAnyOfManyOtherMatchers(self): self.assert_matches( "matcher in the middle", any_of( equal_to("bad"), equal_to("bad"), equal_to("good"), equal_to("bad"), equal_to("bad") ), "good", )
def only_contains(*items): """Matches if each element of sequence satisfies any of the given matchers. :param match1,...: A comma-separated list of matchers. This matcher iterates the evaluated sequence, confirming whether each element satisfies any of the given matchers. Example:: only_contains(less_than(4)) will match ``[3,1,2]``. Any argument that is not a matcher is implicitly wrapped in an :py:func:`~hamcrest.core.core.isequal.equal_to` matcher to check for equality. """ matchers = [] for item in items: matchers.append(wrap_matcher(item)) return IsSequenceOnlyContaining(any_of(*matchers))
def only_contains(*items): """Matches if each element of sequence satisfies any of the given matchers. :param match1,...: A comma-separated list of matchers. This matcher iterates the evaluated sequence, confirming whether each element satisfies any of the given matchers. Example:: only_contains(less_than(4)) will match ``[3,1,2]``. Any argument that is not a matcher is implicitly wrapped in an :py:func:`~hamcrest.core.core.isequal.equal_to` matcher to check for equality. """ matchers = [] for item in items: matchers.append(wrap_matcher(item)) return IsSequenceOnlyContaining(any_of(*matchers))
def testDescribeMismatch(self): self.assert_describe_mismatch( "was 'ugly'", any_of(equal_to("bad"), equal_to("good")), "ugly" )
def testMismatchDescriptionDescribesFirstFailingMatch(self): self.assert_mismatch_description( "was 'ugly'", any_of(equal_to("bad"), equal_to("good")), "ugly" )
def testSuccessfulMatchDoesNotGenerateMismatchDescription(self): self.assert_no_mismatch_description(any_of(equal_to("good"), equal_to("bad")), "good")
def testHasAReadableDescription(self): self.assert_description( "('good' or 'bad' or 'ugly')", any_of(equal_to("good"), equal_to("bad"), equal_to("ugly")), )
def testNoMatchIfArgumentFailsToSatisfyEitherOfTwoOtherMatchers(self): self.assert_does_not_match( "either matcher", any_of(equal_to("bad"), equal_to("bad")), "good" )
def testProvidesConvenientShortcutForMatchingWithEqualTo(self): self.assert_matches("first matcher", any_of("good", "bad"), "good") self.assert_matches("second matcher", any_of("bad", "good"), "good") self.assert_matches("both matchers", any_of("good", "good"), "good")
def testMatchesIfArgumentSatisfiesEitherOrBothOfTwoOtherMatchers(self): self.assert_matches("first matcher", any_of(equal_to("good"), equal_to("bad")), "good") self.assert_matches("second matcher", any_of(equal_to("bad"), equal_to("good")), "good") self.assert_matches("both matchers", any_of(equal_to("good"), equal_to("good")), "good")
def __init__(self, resource_type_matcher, resource_logical_id_matcher): """Init the stack resource matcher class.""" self.resource_type_matcher = resource_type_matcher self.resource_logical_id_matcher = resource_logical_id_matcher self.resource_status_matcher = any_of('UPDATE_COMPLETE', 'CREATE_COMPLETE')