Exemplo n.º 1
0
    def test_match_steps(self):
        """
            Test matching steps from feature files with registered steps
        """
        matcher = Matcher()
        steps = {re.compile(r"Given I have the number (\d+)"): "some_func", re.compile(r"I add (\d+) to my number"): "some_other_func"}

        arguments, keyword_arguments, func = matcher.match("Given I have the number 5", steps)
        arguments.should.be.equal(("5",))
        keyword_arguments.should.be.equal({})
        func.should.be.equal("some_func")

        arguments, keyword_arguments, func = matcher.match("When I add 2 to my number", steps)
        arguments.should.be.equal(("2",))
        keyword_arguments.should.be.equal({})
        func.should.be.equal("some_other_func")

        match = matcher.match("when I call a non-existing step", steps)
        match.should.be.none
Exemplo n.º 2
0
    def test_match_steps(self):
        """
            Test matching steps from feature files with registered steps
        """
        matcher = Matcher()
        steps = {
            re.compile(r"Given I have the number (\d+)"): "some_func",
            re.compile(r"I add (\d+) to my number"): "some_other_func"
        }

        arguments, keyword_arguments, func = matcher.match(
            "Given I have the number 5", steps)
        arguments.should.be.equal(("5", ))
        keyword_arguments.should.be.equal({})
        func.should.be.equal("some_func")

        arguments, keyword_arguments, func = matcher.match(
            "When I add 2 to my number", steps)
        arguments.should.be.equal(("2", ))
        keyword_arguments.should.be.equal({})
        func.should.be.equal("some_other_func")

        match = matcher.match("when I call a non-existing step", steps)
        match.should.be.none