class FizzBuzzTest(unittest.TestCase): def setUp(self): self.fizzBuzz = FizzBuzz() def test_100_entries_are_printed(self): fb = self.fizzBuzz.generate() self.assertEqual(100, len(fb)) self.assertEqual(1, fb[0]) self.assertEqual(98, fb[-3]) def test_multiples_of_three_print_fizz(self): fb = self.fizzBuzz.generate() for i in range(2,101,3): if (i+1) % 5 != 0: self.assertEqual('Fizz', fb[i]) def test_multiples_of_five_print_buzz(self): fb = self.fizzBuzz.generate() for i in range(4,101,5): if (i+1) % 3 != 0: self.assertEqual('Buzz', fb[i]) def test_multiples_of_three_and_five_print_fizzbuzz(self): fb = self.fizzBuzz.generate() for i in range(4,101,5): if (i+1) % 3 == 0: self.assertEqual('FizzBuzz', fb[i])
def test_num10(): actual = FizzBuzz().execute(10) assert actual == "Buzz"
def test_num6(): actual = FizzBuzz().execute(6) assert actual == "Fizz"
def test_num2(): actual = FizzBuzz().execute(2) assert actual == 2
from fizzBuzz import FizzBuzz fizzBuzz = FizzBuzz() print fizzBuzz.generate()
def setUp(self): self.fizzBuzz = FizzBuzz()
def test_0_raises_value_error(self): with self.assertRaises(ValueError): FizzBuzz(0)
def test_2_returns_2(self): assert FizzBuzz(2).result == 2
def test_15_returns_FizzBizz(self): assert FizzBuzz(15).result == "FizzBuzz"
def test_30_returns_FizzBizz(self): assert FizzBuzz(30).result == "FizzBuzz"
def test_10_returns_Buzz(self): assert FizzBuzz(10).result == "Buzz"
def test_5_returns_Buzz(self): assert FizzBuzz(5).result == "Buzz"
def test_6_returns_Fizz(self): assert FizzBuzz(6).result == "Fizz"
def test_num15(): actual = FizzBuzz().execute(15) assert actual == "FizzBuzz"
def test_1_does_not_raise_value_error(self): assert FizzBuzz(1).number == 1
def test_num1(): actual = FizzBuzz().execute(1) assert actual == 1
def test_1_returns_1(self): assert FizzBuzz(1).result == 1