Пример #1
0
def test_handle_initialized(capsys, execution_context, results_set, swagger_20):
    # Given Initialized event
    event = runner.events.Initialized.from_schema(schema=swagger_20)
    # When this even is handled
    default.handle_initialized(execution_context, event)
    out = capsys.readouterr().out
    lines = out.split("\n")
    # Then initial title is displayed
    assert " Schemathesis test session starts " in lines[0]
    # And platform information is there
    assert lines[1].startswith("platform")
    # And current directory
    assert f"rootdir: {os.getcwd()}" in lines
    # And number of collected endpoints
    assert strip_style_win32(click.style("collected endpoints: 1", bold=True)) in lines
    # And the output has an empty line in the end
    assert out.endswith("\n\n")
Пример #2
0
 def handle_event(
     self, context: ExecutionContext, event: events.ExecutionEvent
 ) -> None:
     """Choose and execute a proper handler for the given event."""
     if isinstance(event, events.Initialized):
         default.handle_initialized(context, event)
     if isinstance(event, events.BeforeExecution):
         default.handle_before_execution(context, event)
     if isinstance(event, events.AfterExecution):
         context.hypothesis_output.extend(event.hypothesis_output)
         handle_after_execution(context, event, self.warn)
     if isinstance(event, events.Finished):
         handle_finished(context, event, self.warn, self.statistics)
     if isinstance(event, events.Interrupted):
         default.handle_interrupted(context, event)
     if isinstance(event, events.InternalError):
         handle_internal_error(context, event)