Exemplo n.º 1
0
 def _create_regexp(self, keyword_name):
     if variablematcher.contains_scalar_variable(keyword_name) and \
             not variablematcher.is_variable(keyword_name):
         kw = lambda: 0
         kw.arguments = None
         kw.name = keyword_name
         return EmbeddedArgsHandler(kw).name_regexp
Exemplo n.º 2
0
 def _add_embedded(self, kw):  #添加嵌入
     if '$' not in kw.name:
         return
     try:
         handler = EmbeddedArgsHandler(kw)
         self.embedded_keywords[handler.name_regexp] = kw
     except Exception:
         pass
Exemplo n.º 3
0
 def test_custom_variable_regexp(self):
     args = EmbeddedArgsHandler(KWMock('Say hello to ${user:[A-C]+}'))
     assert_true(args.name_regexp.match('Say hello to ABC'))
     assert_false(args.name_regexp.match('Say hello to ABCD'))
Exemplo n.º 4
0
 def test_several_args(self):
     args = EmbeddedArgsHandler(KWMock('${user} should ${foo} and ${bar}'))
     assert_true(args.name_regexp.match('john should eat and drink'))
     assert_false(args.name_regexp.match('this should not match'))
Exemplo n.º 5
0
 def test_embedded_args(self):
     args = EmbeddedArgsHandler(KWMock('add user ${user} to db'))
     assert_true(args.name_regexp.match('add user test to db'))
     assert_false(args.name_regexp.match('add user test to somewhere else'))