forked from Vauxoo/vauxoo-applicant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.all_unittest.py
75 lines (63 loc) · 2.12 KB
/
.all_unittest.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# pylint: disable=E1601
"""
Script to test python scripts for applicant project
"""
import unittest
from calculator import CalculatorClass
from primes import PrimeClass
class TestApplicantPython(unittest.TestCase):
"""
Main class to test python scripts for applicant project
"""
def setUp(self):
"""
Method init of global unittest class
"""
self.obj_calculator = CalculatorClass()
self.obj_prime = PrimeClass()
def test_10_sum(self):
"""
UnitTest method to check sum method
"""
print "start test:" + \
self.test_10_sum.__doc__
mysum = self.obj_calculator.sum([1, 2, 3, 4, 5, 6])
if mysum != 'not implement yet':
self.assertEqual(mysum, 21, 'incorrect sum method')
print "end test:" + \
self.test_10_sum.__doc__
def test_20_primes(self):
"""
UnitTest method to check primes method
"""
print "start test:" + \
self.test_20_primes.__doc__
if self.obj_prime.is_prime(0) != 'not implement yet':
primes_result = all(
[
self.obj_prime.is_prime(num) is True
for num in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
31, 37, 41, 43, 47, 53, 59, 61, 67,
71, 73, 79, 83, 89, 97, 101, 103, 107]
]
)
self.assertEqual(
primes_result,
True,
'incorrect prime method with primes numbers')
no_primes_result = all(
[
self.obj_prime.is_prime(num) is False
for num in [1, 4, 6, 8, 9, 10, 12, 14,
15, 16, 18, 20, 21, 22, 24,
25]
]
)
self.assertEqual(
no_primes_result,
True,
'incorrect prime method with not primes numbers')
print "end test:" + \
self.test_20_primes.__doc__
if __name__ == '__main__':
unittest.main()