def matches(self, actual): try: match = self.expected.search(actual) except TypeError: return match_failure("Invalid value %s (%s)" % (repr(actual), type(actual))) return match_result(match is not None, got_value(actual))
def matches(self, actual): if actual == self.expected: return match_success() else: return match_failure( "Text does not match:\n%s" % _diff_text(self.expected, actual, self.linesep))
def matches(self, actual): from lemoncheesecake.matching import DISPLAY_DETAILS_WHEN_EQUAL if actual == self.expected: return match_success(got_value( actual)) if DISPLAY_DETAILS_WHEN_EQUAL else match_success() else: return match_failure(got_value(actual))
def matches(self, actual): results = [] for matcher in self.matchers: match = matcher.matches(actual) if match.is_success(): return match results.append(match) return match_failure(merge_match_result_descriptions(results))
def matches(self, actual): if type(actual) in self.types: if self.value_matcher: return self.value_matcher.matches(actual) else: return match_success(got_value(actual)) else: return match_failure( got("%s (%s)" % (serialize_value(actual), get_value_type_name(actual))))
def matches(self, actual): missing = [] for expected in self.expected: if expected not in actual: missing.append(expected) if missing: return match_failure("Missing values: %s" % serialize_values(missing)) else: return match_success(got_value(actual))
def matches(self, actual): try: value = self.key_matcher.get_entry(actual) except KeyError: return match_failure('No entry %s' % self.key_matcher.description()) if self.value_matcher: return self.value_matcher.matches(value) else: return match_success(got_value(value))
def matches(self, actual): expected = list(self.expected) extra = [] for value in actual: if value in expected: expected.remove(value) else: extra.append(value) if len(expected) == 0 and len(extra) == 0: return match_success(got_value(actual)) else: details = [] if len(expected) > 0: details.append("Missing values: %s" % serialize_values(expected)) if len(extra) > 0: details.append("Extra values: %s" % serialize_values(extra)) return match_failure("; ".join(details))
def matches(self, actual): if actual == self.expected: return match_success() else: return match_failure("JSON does not match:\n%s" % _diff_text( _format_json(self.expected), _format_json(actual), "\n"))