Example #1
0
def test_step_matcher_current_matcher():
    current_matcher = matchers.current_matcher
    for name, klass in list(matchers.matcher_mapping.items()):
        matchers.use_step_matcher(name)
        matcher = matchers.get_matcher(lambda x: -x, 'foo')
        assert isinstance(matcher, klass)

    matchers.current_matcher = current_matcher
def test_step_matcher_current_matcher():
    current_matcher = matchers.current_matcher
    for name, klass in list(matchers.matcher_mapping.items()):
        matchers.use_step_matcher(name)
        matcher = matchers.get_matcher(lambda x: -x, 'foo')
        assert isinstance(matcher, klass)

    matchers.current_matcher = current_matcher
Example #3
0
 def add_definition(self, keyword, string, func):
     # TODO try to fix module dependencies to avoid this
     from behave import matchers
     keyword = self.steps[keyword.lower()]
     for existing in keyword:
         if existing.match(string):
             raise AmbiguousStep('"%s" has already been defined' % string)
     keyword.append(matchers.get_matcher(func, string))
Example #4
0
def test_step_matcher_current_matcher():
    current_matcher = matchers.current_matcher
    # XXX-CHECK-PY23: If list() is needed.
    for name, klass in list(matchers.matcher_mapping.items()):
        matchers.use_step_matcher(name)
        matcher = matchers.get_matcher(lambda x: -x, 'foo')
        assert isinstance(matcher, klass)

    matchers.current_matcher = current_matcher
 def add_definition(self, keyword, string, func):
     # TODO try to fix module dependencies to avoid this
     from behave import matchers
     keyword = self.steps[keyword.lower()]
     for existing in keyword:
         if existing.match(string):
             message = '"%s" has already been defined in\n  existing %s'
             raise AmbiguousStep(message % (string, existing.describe()))
     keyword.append(matchers.get_matcher(func, string))
 def add_step_definition(self, keyword, step_text, func):
     step_location = Match.make_location(func)
     step_type = keyword.lower()
     step_text = _text(step_text)
     step_definitions = self.steps[step_type]
     for existing in step_definitions:
         if self.same_step_definition(existing, step_text, step_location):
             # -- EXACT-STEP: Same step function is already registered.
             # This may occur when a step module imports another one.
             return
         elif existing.match(step_text):
             message = u"%s has already been defined in\n  existing step %s"
             new_step = u"@%s('%s')" % (step_type, step_text)
             existing.step_type = step_type
             existing_step = existing.describe()
             existing_step += u" at %s" % existing.location
             raise AmbiguousStep(message % (new_step, existing_step))
     step_definitions.append(get_matcher(func, step_text))
Example #7
0
 def add_step_definition(self, keyword, string, func):
     # TODO try to fix module dependencies to avoid this
     from behave import matchers, model
     step_location = model.Match.make_location(func)
     step_type = keyword.lower()
     step_definitions = self.steps[step_type]
     for existing in step_definitions:
         if self.same_step_definition(existing, string, step_location):
             # -- EXACT-STEP: Same step function is already registered.
             # This may occur when a step module imports another one.
             return
         elif existing.match(string):
             message = '%s has already been defined in\n  existing step %s'
             new_step = u"@%s('%s')" % (step_type, string)
             existing.step_type = step_type
             existing_step = existing.describe()
             existing_step += " at %s" % existing.location
             raise AmbiguousStep(message % (new_step, existing_step))
     step_definitions.append(matchers.get_matcher(func, string))