mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-03-04 22:58:46 +00:00
Add fizz buzz challenge (#149)
This commit is contained in:
37
arrays_strings/fizz_buzz/test_fizz_buzz.py
Normal file
37
arrays_strings/fizz_buzz/test_fizz_buzz.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from nose.tools import assert_equal, assert_raises
|
||||
|
||||
|
||||
class TestFizzBuzz(object):
|
||||
|
||||
def test_fizz_buzz(self):
|
||||
solution = Solution()
|
||||
assert_raises(TypeError, solution.fizz_buzz, None)
|
||||
assert_raises(ValueError, solution.fizz_buzz, 0)
|
||||
expected = [
|
||||
'1',
|
||||
'2',
|
||||
'Fizz',
|
||||
'4',
|
||||
'Buzz',
|
||||
'Fizz',
|
||||
'7',
|
||||
'8',
|
||||
'Fizz',
|
||||
'Buzz',
|
||||
'11',
|
||||
'Fizz',
|
||||
'13',
|
||||
'14',
|
||||
'FizzBuzz'
|
||||
]
|
||||
assert_equal(solution.fizz_buzz(15), expected)
|
||||
print('Success: test_fizz_buzz')
|
||||
|
||||
|
||||
def main():
|
||||
test = TestFizzBuzz()
|
||||
test.test_fizz_buzz()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user