Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_display_section_name(capsys, title, separator, printed, expected):
# When section name is displayed
default.display_section_name(title, separator=separator)
out = capsys.readouterr().out.strip()
terminal_width = default.get_terminal_width()
# It should fit into the terminal width
assert len(click.unstyle(out)) == terminal_width
# And the section name should be bold
assert click.style(click.unstyle(out), bold=True) == out
assert expected in out
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() == click.style(percentage, fg="cyan")