Пример #1
0
def test_stacked_multiline_servers(fake_results, capfd):
    """If width is narrow enough it should list servers on multiple lines."""

    formatting.stacked_results(fake_results, {"width": 45})

    stdout, _ = capfd.readouterr()

    expected = [
        "server_a_1, server_a_2, server_a_3,",
        "server_a_4",
        "---------------------------------------------",
        "hello world",
        "cat: dog: No such file or directory",
        "=============================================",
        "server_b_1, server_b_2, server_b_3",
        "---------------------------------------------",
        "hello world",
        "cat: cat: No such file or directory",
        "=============================================",
        "server_c_1",
        "---------------------------------------------",
        "hello world",
        "cat: dog: No such file or directory",
        "hello world",
        "cat: cat: No such file or directory\n",
    ]

    assert stdout == "\n".join(expected)
Пример #2
0
def test_stacked_results(fake_results, capfd):
    """Ensure the formatting for stacked/flat results."""

    formatting.stacked_results(fake_results, {"width": 55})

    stdout, _ = capfd.readouterr()

    expected = [
        "server_a_1, server_a_2, server_a_3, server_a_4",
        "-------------------------------------------------------",
        "hello world",
        "cat: dog: No such file or directory",
        "=======================================================",
        "server_b_1, server_b_2, server_b_3",
        "-------------------------------------------------------",
        "hello world",
        "cat: cat: No such file or directory",
        "=======================================================",
        "server_c_1",
        "-------------------------------------------------------",
        "hello world",
        "cat: dog: No such file or directory",
        "hello world",
        "cat: cat: No such file or directory\n",
    ]

    assert stdout == "\n".join(expected)
Пример #3
0
def cmdline_exit(results, options):
    """A buffer for selecting the correct output function and exiting.

    Args::

        results: the results dictionary from Bladerunner.run
        options: the options dictionary, uses 'style' and 'stacked' keys
    """

    if options.get("stacked"):
        stacked_results(results, options)
    elif options["style"] < 0 or options["style"] > 3:
        csv_results(results, options)
    else:
        pretty_results(results, options)

    raise SystemExit