Пример #1
0
def test_print_nofizznobuzz(capsys):
    """Tests if display_fizzbuzz prints non-multiples correctly to stdout"""
    display_fizzbuzz(4)
    out, err = capsys.readouterr()
    assert out == "4\n"
    display_fizzbuzz(11)
    out, err = capsys.readouterr()
    assert out == "11\n"
    display_fizzbuzz(98)
    out, err = capsys.readouterr()
    assert out == "98\n"
Пример #2
0
def test_print_buzz(capsys):
    """Tests if display_fizzbuzz prints Buzz correctly to stdout"""
    display_fizzbuzz(5)
    out, err = capsys.readouterr()
    assert out == "Buzz\n"
    display_fizzbuzz(10)
    out, err = capsys.readouterr()
    assert out == "Buzz\n"
    display_fizzbuzz(55)
    out, err = capsys.readouterr()
    assert out == "Buzz\n"
Пример #3
0
def test_print_fizzbuzz(capsys):
    """Tests if display_fizzbuzz prints FizzBuzz correctly to stdout"""
    display_fizzbuzz(15)
    out, err = capsys.readouterr()
    assert out == "FizzBuzz\n"
    display_fizzbuzz(30)
    out, err = capsys.readouterr()
    assert out == "FizzBuzz\n"
    display_fizzbuzz(60)
    out, err = capsys.readouterr()
    assert out == "FizzBuzz\n"
Пример #4
0
def test_invalid_input_display_fizzbuzz():
    """Tests display_fizzbuzz handling of invalid input"""
    with pytest.raises(ValueError):
        display_fizzbuzz('FAIL')
    with pytest.raises(ValueError):
        display_fizzbuzz(3.5)