def test_after_each_step_failed(self): """ Test after.each_step from extension console_writer with failed step """ data = threading.local() data.console = None def patched_write(text): text = re.sub(r"\x1b[^m]*m", "", text) data.console = text scenario_mock = Mock() scenario_mock.parent = None step = Step(1, "I test the console writer", "somefile.feature", 3, scenario_mock, False) step.parent = MagicMock() step.parent.id = 1 step.parent.parent = Mock(spec=Feature) step.parent.parent.id = 1 step.state = step.State.FAILED try: assert False, "Some assertion happend" except AssertionError as e: step.failure = utils.Failure(e) with patch("radish.extensions.console_writer.write", side_effect=patched_write): HookRegistry().call("after", "each_step", step) data.console.should.be.equal("""\rI test the console writer AssertionError: Some assertion happend""")
def test_after_each_step(self): """ Test after.each_step 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_mock = Mock() scenario_mock.parent = None step = Step(1, "I test the console writer", "somefile.feature", 3, scenario_mock, False) step.parent = Mock() step.parent.id = 1 step.parent.parent = Mock(spec=Feature) step.parent.parent.id = 1 with patch("radish.extensions.console_writer.write", side_effect=patched_write): HookRegistry().call("after", "each_step", step) data.console.should.be.equal("\rI test the console writer")