interactive-coding-challenges/math_probability/generate_primes/test_generate_primes.py

27 lines
991 B
Python
Raw Permalink Normal View History

import unittest
2017-03-29 16:45:04 +08:00
class TestMath(unittest.TestCase):
2017-03-29 16:45:04 +08:00
def test_generate_primes(self):
prime_generator = PrimeGenerator()
self.assertRaises(TypeError, prime_generator.generate_primes, None)
self.assertRaises(TypeError, prime_generator.generate_primes, 98.6)
self.assertEqual(prime_generator.generate_primes(20), [False, False, True,
2017-03-29 16:45:04 +08:00
True, False, True,
False, True, False,
False, False, True,
False, True, False,
False, False, True,
False, True])
print('Success: generate_primes')
def main():
test = TestMath()
test.test_generate_primes()
if __name__ == '__main__':
main()