def verify_all(all_metrics, matchers): """Verified that every matcher matches a metric result in all_metrics.""" errors = [] matched_metrics = [] for matcher in matchers: matched_metrics = [mr for mr in all_metrics if matcher.matches(mr)] if not matched_metrics: errors.append('Unable to match metrics for matcher %s' % (string_description.tostring(matcher))) if errors: errors.append('\nActual MetricResults:\n' + '\n'.join([str(mr) for mr in all_metrics])) return ''.join(errors)
def verify_all(all_metrics, matchers): """Verified that every matcher matches a metric result in all_metrics.""" errors = [] matched_metrics = [] for matcher in matchers: matched_metrics = [mr for mr in all_metrics if matcher.matches(mr)] if not matched_metrics: errors.append('Unable to match metrics for matcher %s' % ( string_description.tostring(matcher))) if errors: errors.append('\nActual MetricResults:\n' + '\n'.join([str(mr) for mr in all_metrics])) return ''.join(errors)
def testMatcherReprIsMatcher(self): matcher = equal_to('bar') assert repr(match_equality(matcher)) == tostring(matcher)
def testMatcherStringIsMatcherDescription(self): matcher = equal_to('bar') assert str(match_equality(matcher)) == tostring(matcher)
def __str__(self): return tostring(self)
def __repr__(self): return tostring(self.matcher)
def __repr__(self) -> str: """Returns matcher string representation.""" return "<{0}({1})>".format( self.__class__.__name__, shorten(tostring(self), 60, placeholder="..."))
def __str__(self) -> str: return tostring(self)