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