Example #1
0
    def test_before_each_scenario(self):
        """
            Test before.each_scenario from extension console_writer
        """
        data = threading.local()
        data.console = None

        def patched_write(text):
            text = re.sub(r"\x1b[^m]*m", "", text)
            data.console = text

        scenario = Scenario(1, "Scenario", "Some scenario", "somefile.feature", 2, None)
        scenario.parent = Mock(spec=Feature)
        scenario.parent.id = 1

        with patch("radish.extensions.console_writer.write", side_effect=patched_write):
            HookRegistry().call("before", "each_scenario", scenario)

            data.console.should.be.equal("\n    Scenario: Some scenario")
Example #2
0
    def test_before_each_scenario(self):
        """
            Test before.each_scenario from extension console_writer
        """
        data = threading.local()
        data.console = None

        def patched_write(text):
            text = re.sub(r"\x1b[^m]*m", "", text)
            data.console = text

        scenario = Scenario(1, "Scenario", "Some scenario", "somefile.feature",
                            2, None)
        scenario.parent = Mock(spec=Feature)
        scenario.parent.id = 1

        with patch("radish.extensions.console_writer.write",
                   side_effect=patched_write):
            HookRegistry().call("before", "each_scenario", scenario)

            data.console.should.be.equal("\n    Scenario: Some scenario")