예제 #1
0
def handle_after_execution(
    context: ExecutionContext, event: events.AfterExecution, warnings: FrozenSet[str]
) -> None:
    """Display the execution result + current progress at the same line with the method / endpoint names."""
    context.endpoints_processed += 1
    context.results.append(event.result)
    display_execution_result(context, event, warnings)
    default.display_percentage(context, event)
예제 #2
0
def test_display_percentage(
    capsys, execution_context, after_execution, swagger_20, current_line_length, endpoints_processed, percentage
):
    execution_context.current_line_length = current_line_length
    execution_context.endpoints_processed = endpoints_processed
    # When percentage is displayed
    default.display_percentage(execution_context, after_execution)
    out = capsys.readouterr().out
    # Then the whole line fits precisely to the terminal width
    assert len(click.unstyle(out)) + current_line_length == default.get_terminal_width()
    # And the percentage displayed as expected in cyan color
    assert out.strip() == strip_style_win32(click.style(percentage, fg="cyan"))
예제 #3
0
def test_display_percentage(
    capsys, execution_context, after_execution, swagger_20, current_line_length, operations_processed, percentage
):
    execution_context.current_line_length = current_line_length
    execution_context.operations_processed = operations_processed
    # When percentage is displayed
    default.display_percentage(execution_context, after_execution)
    out = capsys.readouterr().out
    # Then the whole line fits precisely to the terminal width. Note `-1` is padding, that is calculated in a
    # different place when the line is printed
    assert len(click.unstyle(out)) + current_line_length - 1 == default.get_terminal_width()
    # And the percentage displayed as expected in cyan color
    assert out.strip() == strip_style_win32(click.style(percentage, fg="cyan"))