def throws_an_error_if_fizz_has_no_input(): """Makes sure fizz() throws an error if there is no input""" with raises(Exception) as err_info: fizz() # pylint: disable=no-value-for-parameter assert err_info.type == TypeError assert 'missing 1 required positional argument' in str( err_info.value)
def can_determine_if_a_given_number_is_a_multiple_of_3(): """Checks to see if a given number is a multiple of 3.""" assert fizz(3) == True # multiple of 3 assert fizz(2) == False # non-multiple of 3 assert fizz(3.5) == False # non-integer assert fizz(0) == True # zero assert fizz(-3) == True # negative multiple of 3 assert fizz(-4) == False # negative non-multiple of 3 assert fizz('buzz') == False # non-numeric input assert fizz() == False # if no input
def outputs_fizz_if_an_input_is_numeric_and_a_multiple_of_3(): """ Checks to see if the input `x` is numeric and a multiple of 3. If it is, it outputs 'Fizz'. Otherwise, it outputs the input. """ assert fizz(3) == 'Fizz' # multiple of 3 assert fizz(4) == 4 # non-multiple of 3 assert fizz(0) == 'Fizz' # zero assert fizz(15) == 'Fizz' # multiple of 3 and 5 assert fizz(-3) == 'Fizz' # negative multiple of 3 assert fizz(-2) == -2 # negative non-multiple of 3 assert fizz(3.5) == 3.5 # non-integer assert fizz('Buzz') == 'Buzz' # non-numeric
def returns_fizz_if_a_number_is_a_multiple_of_3(): """ Takes an input `x` and checks to see if it is a number, and if so, also a multiple of 3. If it is both, return 'Fizz'. Otherwise, return the input. """ assert fizz(3) == 'Fizz' # multiple of 3 assert fizz(2) == 2 # non-multiple of 3 assert fizz(3.5) == 3.5 # non-integer assert fizz(0) == 'Fizz' # zero assert fizz(-3) == 'Fizz' # negative multiple of 3 assert fizz(-4) == -4 # negative non-multiple of 3 assert fizz('Buzz') == 'Buzz' # non-numeric input
def returns_fizz_if_x_is_multiple_of_3(): """ Checks to see if an input is a multiple of 3. Returns 'Fizz' if it is. Returns the input if it is not. """ assert fizz(3) == 'Fizz' # multiple of 3 assert fizz(2) == 2 # non-multiple of 3 assert fizz(0) == 'Fizz' # zero assert fizz(-3) == 'Fizz' # negative multiple of 3 assert fizz(-4) == -4 # negative non-multiple of 3 assert fizz('Buzz') == 'Buzz' # non-number input
def test_contiene_3(): assert fizz(32) == "Fizz" assert fizz(73) == "Fizz" assert fizz(63) == "Fizz"
def test_divible_3_5(): assert fizz(15) == "FizzBuzz" assert fizz(30) == "FizzBuzz" assert fizz(45) == "FizzBuzz"
def test_returns_not_divisible_when_not_divisible_by_both_three_and_five(self): ''' Test that returns fizz when input is not divisible by three and five ''' self.assertEqual(fizzbuzz.fizz(17),'Number not divisible by 3 and 5')
def test_returns_fizz_when_divisible_by_three(self): ''' Test that returns fizz when input is divisible by three ''' self.assertEqual(fizzbuzz.fizz(3),'Fizz')
def test_returns_buzz_when_divisible_by_five(self): ''' Test that returns fizz when input is divisible by five ''' self.assertEqual(fizzbuzz.fizz(5),'Buzz')
def test_returns_fizzbuzz_when_divisible_by_both_three_and_five(self): ''' Test that returns fizz when input is divisible by three and five ''' self.assertEqual(fizzbuzz.fizz(15),'FizzBuzz')
def throws_an_error_if_no_input(): with raises(Exception) as err_info: fizz() # pylint: disable=no-value-for-parameter assert err_info.type == TypeError assert 'missing 1 required positional argument' in str( err_info.value)
def test_divisible3(): assert fizz(3) == "Fizz" assert fizz(6) == "Fizz" assert fizz(9) == "Fizz"
def test_no_divisible(): assert fizz(4) == 4 assert fizz(7) == 7 assert fizz(1) == 1 assert fizz(16) == 16
def test_contiene_5(): assert fizz(65) == "Buzz" assert fizz(52) == "Buzz" assert fizz(58) == "Buzz"
def throws_an_error_if_no_input(): with raises(Exception) as exception_info: fizz() # pylint: disable=no-value-for-parameter assert exception_info.type == TypeError assert "missing 1 required positional argument" in str(exception_info.value) def returns_fizz_if_x_is_multiple_of_3(): """ Checks to see if an input is a multiple of 3. Returns 'Fizz' if it is. Returns the input if it is not. """ assert fizz(3) == 'Fizz' # multiple of 3 assert fizz(2) == 2 # non-multiple of 3 assert fizz(0) == 'Fizz' # zero assert fizz(-3) == 'Fizz' # negative multiple of 3 assert fizz(-4) == -4 # negative non-multiple of 3 assert fizz('Buzz') == 'Buzz' # non-number input def describes_a_function_buzz_that(): """Tests related to our buzz() function""" 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 test_divisible5(): assert fizz(5) == "Buzz" assert fizz(10) == "Buzz" assert fizz(20) == "Buzz"
def test_contiene_3_5(): assert fizz(35) == "FizzBuzz" assert fizz(53) == "FizzBuzz"