def throws_an_error_if_buzz_has_no_input(): """Makes sure buzz() throws an error if there is no input""" with raises(Exception) as err_info: buzz() # pylint: disable=no-value-for-parameter assert err_info.type == TypeError assert 'missing 1 required positional argument' in str( err_info.value)
def throws_an_error_if_no_input(): with raises(Exception) as exception_info: buzz() # pylint: disable=no-value-for-parameter assert exception_info.type == TypeError assert "missing 1 required positional argument" in str(exception_info.value) def returns_buzz_if_x_is_multiple_of_5(): """ Checks to see if an input is a multiple of 5. Returns 'Buzz' if it is. Returns the input if it is not. """ assert buzz(5) == 'Buzz' # multiple of 5 assert buzz(2) == 2 # non-multiple of 5 assert buzz(0) == 'Buzz' # zero assert buzz(-5) == 'Buzz' # negative multiple of 5 assert buzz(-4) == -4 # negative non-multiple of 5 assert buzz('Fizz') == 'Fizz' # non-number input def describes_a_function_fibu_that(): """Tests related to our fibu() function""" def throws_an_error_if_no_input(): with raises(Exception) as exception_info: fibu() # pylint: disable=no-value-for-parameter assert exception_info.type == TypeError assert "missing 1 required positional argument" in str(exception_info.value) def returns_fizzbuzz_if_x_is_multiple_of_15(): """ Checks to see if an input is a multiple of 15. Returns 'FizzBuzz' if it is. Returns the input if it is not. """ assert fibu(15) == 'FizzBuzz' # multiple of 15 assert fibu(2) == 2 # non-multiple of 15 assert fibu(0) == 'FizzBuzz' # zero assert fibu(-15) == 'FizzBuzz' # negative multiple of 15 assert fibu(-4) == -4 # negative non-multiple of 15 assert fibu('Fizz') == 'Fizz' # non-number input def can_play_fizzbuzz(): """Demonstrate that we can generate the correct output for a minimal test case of the actual FizzBuzz game. """ assert play_fizzbuzz(1, 15) == [ 1, 2, 'Fizz', 4, 'Buzz', 'Fizz', 7 , 8, 'Fizz', 'Buzz', 11, 'Fizz', 13, 14, 'FizzBuzz' ]
def outputs_buzz_if_an_input_is_numeric_and_a_multiple_of_5(): """ Checks to see if the input `x` is numeric and a multiple of 5. If it is, it outputs 'Buzz'. Otherwise, it outputs the input. """ assert buzz(5) == 'Buzz' # multiple of 5 assert buzz(4) == 4 # non-multiple of 5 assert buzz(0) == 'Buzz' # zero assert buzz(15) == 'Buzz' # multiple of 5 and 5 assert buzz(-5) == 'Buzz' # negative multiple of 5 assert buzz(-2) == -2 # negative non-multiple of 5 assert buzz(5.5) == 5.5 # non-integer assert buzz('Fizz') == 'Fizz' # non-numeric
def returns_buzz_if_a_number_is_a_multiple_of_5(): """ Takes an input `x` and checks to see if it is a number, and if so, also a multiple of 5. If it is both, return 'Buzz'. Otherwise, return the input. """ assert buzz(5) == 'Buzz' # multiple of 5 assert buzz(2) == 2 # non-multiple of 5 assert buzz(5.5) == 5.5 # non-integer assert buzz(0) == 'Buzz' # zero assert buzz(-5) == 'Buzz' # negative multiple of 5 assert buzz(-4) == -4 # negative non-multiple of 5 assert buzz('Fizz') == 'Fizz' # non-numeric input
def returns_buzz_if_x_is_multiple_of_5(): """ Checks to see if an input is a multiple of 5. Returns 'Buzz' if it is. Returns the input if it is not. """ assert buzz(5) == 'Buzz' # multiple of 5 assert buzz(2) == 2 # non-multiple of 5 assert buzz(0) == 'Buzz' # zero assert buzz(-5) == 'Buzz' # negative multiple of 5 assert buzz(-4) == -4 # negative non-multiple of 5 assert buzz('Fizz') == 'Fizz' # non-number input
def throws_an_error_if_no_input(): with raises(Exception) as err_info: buzz() # pylint: disable=no-value-for-parameter assert err_info.type == TypeError assert 'missing 1 required positional argument' in str( err_info.value)