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)
Example #3
0
 def testMatcherReprIsMatcher(self):
     matcher = equal_to('bar')
     assert repr(match_equality(matcher)) == tostring(matcher)
Example #4
0
 def testMatcherStringIsMatcherDescription(self):
     matcher = equal_to('bar')
     assert str(match_equality(matcher)) == tostring(matcher)
Example #5
0
 def __str__(self):
     return tostring(self)
Example #6
0
 def __repr__(self):
     return tostring(self.matcher)
Example #7
0
 def __repr__(self) -> str:
     """Returns matcher string representation."""
     return "<{0}({1})>".format(
         self.__class__.__name__,
         shorten(tostring(self), 60, placeholder="..."))
Example #8
0
 def __str__(self) -> str:
     return tostring(self)
Example #9
0
 def __str__(self):
     return tostring(self)