def test_non_fizzbuzz_number(self): """_Number stringifies as the number when not divisible by 3 nor 5""" for i in [2, 13, 1001]: n = fizzbuzz._Number(i) self.assertFalse(n.is_fizz()) self.assertFalse(n.is_buzz()) self.assertFalse(n.is_fizzbuzz()) self.assertEqual(str(n), str(i))
def test_is_fizzbuzz(self): """_Number.is_fizzbuzz()""" self.assertTrue(fizzbuzz._Number(0).is_fizzbuzz()) self.assertTrue(fizzbuzz._Number(15).is_fizzbuzz()) self.assertFalse(fizzbuzz._Number(5).is_fizzbuzz()) self.assertFalse(fizzbuzz._Number(3).is_fizzbuzz())
def test_fizzbuzz_number(self): """_Number stringifies as 'fizzbuzz' when divisible by 3 and 5""" for i in [0, 15, 225]: n = fizzbuzz._Number(i) self.assertTrue(n.is_fizzbuzz()) self.assertEqual(str(n), 'fizzbuzz')
def test_buzz_number(self): """_Number stringifies as 'buzz' when divisible by 3""" for i in [5, 10, 500]: n = fizzbuzz._Number(i) self.assertEqual(str(n), 'buzz')
def test_fizz_number(self): """_Number stringifies as 'fizz' when divisible by 3""" for i in [3, 6, 333]: n = fizzbuzz._Number(i) self.assertEqual(str(n), 'fizz')
def test_negative_number(self): """_Number doesn't allow negative numbers""" with self.assertRaises(ValueError): fizzbuzz._Number(-5)