-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
25 lines (20 loc) · 885 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# coding=utf-8
import unittest
from primes import is_prime
class PrimesTestCase(unittest.TestCase):
"""Tests for primes.py"""
def test_is_five_prime(self):
"""Is five successfully determined to be prime?"""
self.assertTrue(is_prime(5))
def test_is_four_prime(self):
"""Is five successfully determined to be prime?"""
self.assertFalse(is_prime(4),msg="Four is not prime")
def test_is_zero_not_prime(self):
"""Is zero correctly determined not to be prime?"""
self.assertFalse(is_prime(0),msg = "Zero is not prime")
def test_negative_number(self):
"""Is a negative number correctly determined not to be prime?"""
for index in range(-1, -10, -1):
self.assertFalse(is_prime(index), msg='{} should not be determined to be prime'.format(index))
if __name__ == '__main__':
unittest.main()