def test_002(self): for i in range(3,15,3): self.assertEqual(fizzbuzz(i), "Fizz") for i in range(5,15,5): self.assertEqual(fizzbuzz(i), "Buzz")
def test_fizzbuzz(self): self.assertEqual(fizzbuzz(3), "Fizz") self.assertEqual(fizzbuzz(12), "Fizz") self.assertEqual(fizzbuzz(5), "Buzz") self.assertEqual(fizzbuzz(25), "Buzz") self.assertEqual(fizzbuzz(15), "FizzBuzz") self.assertEqual(fizzbuzz(4), "") self.assertEqual(fizzbuzz(8), "")
def test_5_renvoie_5(self): self.assertEqual("buzz", fizzbuzz(5))
def test_retorna_1_ao_receber_1(self): self.assertEqual(fizzbuzz(1), '1')
def test_fizzbuzz(self): self.assertEqual(fizzbuzz(1), 1)
def test_retorna_4_ao_receber_4(self): self.assertEqual(fizzbuzz(4), '4')
def test_retorna_fizz_ao_receber_10(self): self.assertEqual(fizzbuzz(10), 'buzz')
def test_entra_1_sai_1(self): self.assertEqual(fizzbuzz(1), '1')
def test_3_renvoie_3(self): self.assertEqual("fizz", fizzbuzz(3))
def test_entra_15_sai_FizzBuzz(self): self.assertEqual(fizzbuzz(15), DIV3 + DIV5)
def test_001(self): self.assertEqual(fizzbuzz(15), "FizzBuzz")
def test_000(self): self.assertEqual(fizzbuzz(0), "FizzBuzz")
def test_answer(): assert fizzbuzz(3) == 'Fizz' assert fizzbuzz(5) == 'Buzz' assert fizzbuzz(15) == 'FizzBuzz' assert fizzbuzz(4) == 4
# expect(result).to(equal('Buzz')) # with context ('When number is 15'): # with it('Returns FizzBuzz'): # number = 15 # # result = fizzbuzz(number) # expect(result).to(equal('FizzBuzz')) with context('When number is divisible by 3'): with context('and not by 5'): with it('Returns Fizz'): numbers = [6, 9, 12] for number in numbers: result = fizzbuzz(number) expect(result).to(equal('Fizz')) with context('When number is divisible by 5 and not by 3'): with it('Returns Buzz'): numbers = [5, 10, 20, 100] for number in numbers: result = fizzbuzz(number) expect(result).to(equal('Buzz')) with context('When number is divisible by 15 and does not have a 3'): with it('Returns FizzBuzz'): numbers = [15, 45, 60, 75, 90]
""" We will use this script to teach Python to absolute beginners The script is an example of Fizz-Buzz implemented in Python The FizzBuzz problem: For all integers between 1 and 99 (include both): # print fizz for multiples of 3 # print buzz for multiples of 5 # print fizzbuzz for multiples of 3 and 5" """ import fizzbuzz #----START OF SCRIPT if __name__=='__main__': fizzbuzz(100)
def test_entra_30_sai_FizzBuzz(self): self.assertEqual(fizzbuzz(30), DIV3 + DIV5)
def test_6_renvoie_6(self): self.assertEqual("fizz", fizzbuzz(6))
def test_entra_2_sai_2(self): self.assertEqual(fizzbuzz(2), '2')
def test_10_renvoie_10(self): self.assertEqual("buzz", fizzbuzz(10))
def test_retorna_buzz_ao_receber_5(self): self.assertEqual(fizzbuzz(5), 'buzz')
def test_15_renvoie_15(self): self.assertEqual("fizzbuzz", fizzbuzz(15))
def test_retorna_fizzbuzz_ao_receber_15(self): self.assertEqual(fizzbuzz(15), 'fizzbuzz')
def test_30_renvoie_30(self): self.assertEqual("fizzbuzz", fizzbuzz(30))
def test_retorna_2_ao_receber_2(self): self.assertEqual(fizzbuzz(2), '2')
def test_50_renvoie_50(self): self.assertEqual("buzz", fizzbuzz(50))
def test_1_renvoie_1(self): self.assertEqual(1, fizzbuzz(1))
def test_2_renvoie_2(self): self.assertEqual(2, fizzbuzz(2))
def test_entra_multiplo3_naomultiplo5_sai_Fizz(self): self.assertEqual(fizzbuzz(3), DIV3) self.assertEqual(fizzbuzz(6), DIV3) self.assertEqual(fizzbuzz(9), DIV3)
def test_fizzbuzz(self): self.assertEqual(fizzbuzz(3), 'fizz')
def test_entra_multiplo5_naomultiplo3_sai_Buzz(self): self.assertEqual(fizzbuzz(5), DIV5) self.assertEqual(fizzbuzz(10), DIV5) self.assertEqual(fizzbuzz(20), DIV5)