mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
38 lines
761 B
Python
38 lines
761 B
Python
import unittest
|
|
|
|
|
|
class TestFizzBuzz(unittest.TestCase):
|
|
|
|
def test_fizz_buzz(self):
|
|
solution = Solution()
|
|
self.assertRaises(TypeError, solution.fizz_buzz, None)
|
|
self.assertRaises(ValueError, solution.fizz_buzz, 0)
|
|
expected = [
|
|
'1',
|
|
'2',
|
|
'Fizz',
|
|
'4',
|
|
'Buzz',
|
|
'Fizz',
|
|
'7',
|
|
'8',
|
|
'Fizz',
|
|
'Buzz',
|
|
'11',
|
|
'Fizz',
|
|
'13',
|
|
'14',
|
|
'FizzBuzz'
|
|
]
|
|
self.assertEqual(solution.fizz_buzz(15), expected)
|
|
print('Success: test_fizz_buzz')
|
|
|
|
|
|
def main():
|
|
test = TestFizzBuzz()
|
|
test.test_fizz_buzz()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|