def test_should_fizzify_n_numbers_correctly(n, expected): assert fizzbuzz(n) == expected
def test_fizzbuzz_is_generator(): actual_results = fizzbuzz(5) assert isinstance(actual_results, types.GeneratorType)
def test_fizzbuzz_is_fizzbuzz(): N = 45 actual_results = list(fizzbuzz(N)) for i in range(15, N + 1, 15): assert actual_results[i - 1] == "fizzbuzz"
def test_fizzbuzz_is_buzz(): N = 15 actual_results = list(fizzbuzz(N)) for i in range(5, N + 1, 5): assert actual_results[i - 1].endswith("buzz")
def test_fizzbuzz_is_fizz(): N = 15 actual_results = list(fizzbuzz(N)) for i in range(3, N + 1, 3): assert actual_results[i - 1].startswith("fizz")
# coding: utf-8 import sys from solution import fizzbuzz if __name__ == "__main__": if len(sys.argv) != 3: print("Usage: .py <int> <int>") sys.exit(1) begin = int(sys.argv[1]) end = int(sys.argv[2]) # Call the function fizzbuzz(begin, end)