示例#1
0
def test_print_colors(input_mock, capfd):
    not_valid = 'Not a valid color'
    expected = '\n'.join(['blue', 'yellow', not_valid, 'red',
                          not_valid, 'bye'])

    print_colors()

    output = capfd.readouterr()[0].strip()
    assert output == expected
示例#2
0
def test_print_colors(input_mock, capfd):
    not_valid = "Not a valid color"
    expected = "\n".join(
        ["blue", "yellow", not_valid, "red", not_valid, "bye"])

    print_colors()

    output = capfd.readouterr()[0].strip()
    assert output == expected
示例#3
0
def test_print_colors(input_mock, capsys):
    not_valid = 'Not a valid color'
    expected = '\n'.join(
        ['blue', 'yellow', not_valid, 'red', not_valid, 'bye'])

    # this allows using sys.exit instead of break
    try:
        print_colors()
    except SystemExit:
        pass

    output = capsys.readouterr()[0].strip()
    assert output == expected
示例#4
0
def test_print_colors(input_mock, capsys):
    not_valid = "Not a valid color"
    expected = "\n".join(
        ["blue", "yellow", not_valid, "red", not_valid, "bye"])

    # this allows using sys.exit instead of break
    try:
        print_colors()
    except SystemExit:
        pass

    output = capsys.readouterr()[0].strip()
    assert output == expected
示例#5
0
def call_print_colors():
    # some people prefer sys.exit instead of break
    try:
        print_colors()
    except SystemExit:
        pass