def test_parse_matchers__without_provider(self):
     unit = TestPlanUnit({}, provider=None)
     self.assertEqual(
         list(unit.parse_matchers("foo")),
         [(0, 'id', OperatorMatcher(operator.eq, 'foo'), None)])
     self.assertEqual(
         list(unit.parse_matchers("other::bar")),
         [(0, 'id', OperatorMatcher(operator.eq, "other::bar"), None)])
     self.assertEqual(list(unit.parse_matchers("sd[a-z]")),
                      [(0, 'id', PatternMatcher("^sd[a-z]$"), None)])
     self.assertEqual(list(unit.parse_matchers("sd[a-z]$")),
                      [(0, 'id', PatternMatcher("^sd[a-z]$"), None)])
     self.assertEqual(list(unit.parse_matchers("^sd[a-z]")),
                      [(0, 'id', PatternMatcher("^sd[a-z]$"), None)])
     self.assertEqual(list(unit.parse_matchers("^sd[a-z]$")),
                      [(0, 'id', PatternMatcher("^sd[a-z]$"), None)])
示例#2
0
 def visit_IncludeStmt_node(self, node: IncludeStmt):
     if isinstance(node.pattern, ReErr):
         matcher = None
         error = node.pattern.exc
     elif isinstance(node.pattern, ReFixed):
         target_id = outer_self.qualify_id(node.pattern.text)
         matcher = OperatorMatcher(operator.eq, target_id)
         error = None
     elif isinstance(node.pattern, RePattern):
         text = node.pattern.text
         # Ensure that pattern is surrounded by ^ and $
         if text.startswith('^') and text.endswith('$'):
             target_id_pattern = '^{}$'.format(
                 outer_self.qualify_id(text[1:-1]))
         elif text.startswith('^'):
             target_id_pattern = '^{}$'.format(
                 outer_self.qualify_id(text[1:]))
         elif text.endswith('$'):
             target_id_pattern = '^{}$'.format(
                 outer_self.qualify_id(text[:-1]))
         else:
             target_id_pattern = '^{}$'.format(
                 outer_self.qualify_id(text))
         matcher = PatternMatcher(target_id_pattern)
         error = None
     result = (node.lineno, 'id', matcher, error)
     self.results.append(result)
示例#3
0
 def visit_IncludeStmt_node(self, node: IncludeStmt):
     if isinstance(node.pattern, ReFixed):
         target_id = testplan.qualify_id(node.pattern.text)
         matcher = OperatorMatcher(operator.eq, target_id)
     elif isinstance(node.pattern, RePattern):
         pattern = testplan.qualify_pattern(node.pattern.text)
         matcher = PatternMatcher(pattern)
     result = (node.lineno, 'id', matcher)
     results.append(result)
示例#4
0
 def test_repr(self):
     self.assertEqual(repr(PatternMatcher("text")),
                      "PatternMatcher('text')")
示例#5
0
 def test_match(self):
     matcher = PatternMatcher("foo.*")
     self.assertTrue(matcher.match("foobar"))
     self.assertFalse(matcher.match("fo"))
示例#6
0
 def test_match(self):
     matcher = PatternMatcher("foo.*")
     self.assertTrue(matcher.match("foobar"))
     self.assertFalse(matcher.match("fo"))