Skip to content

Instantly share code, notes, and snippets.

@isidore
Created May 5, 2017 16:59
Show Gist options
  • Save isidore/c7f439ba5578d9ce17165ec05d5a4bc7 to your computer and use it in GitHub Desktop.
Save isidore/c7f439ba5578d9ce17165ec05d5a4bc7 to your computer and use it in GitHub Desktop.
from unittest import TestCase
def fizzbuzz(i):
#FIZZ when number 3
if i % 3 == 0 and i % 5 == 0:
return "FIZZBUZZ"
if i % 3 == 0:
return "FIZZ"
if i % 5 == 0:
return "BUZZ"
return str(i)
class FizzBuzzTest(TestCase):
def test_1(self):
#when we ask for 1
result = fizzbuzz(1)
#verify result = 1
self.assertEquals(result,"1")
def test_2(self):
result = fizzbuzz(2)
self.assertEquals(result, "2")
def test_3(self):
result = fizzbuzz(3)
self.assertEquals(result, "FIZZ")
def test_5(self):
result = fizzbuzz(5)
self.assertEquals(result, "BUZZ")
def test_6(self):
result = fizzbuzz(6)
self.assertEquals(result, "FIZZ")
def test_10(self):
result = fizzbuzz(10)
self.assertEquals(result, "BUZZ")
def test_15(self):
result = fizzbuzz(15)
self.assertEquals(result, "FIZZBUZZ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment