-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
37 lines (25 loc) · 719 Bytes
/
test.py
File metadata and controls
37 lines (25 loc) · 719 Bytes
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
import unittest
from mymod import plus1, myclass
import mypack
class TestPlus1(unittest.TestCase):
def test_plus1(self):
# can hardcode tests
self.assertEqual(plus1(1), 2)
# can generate tests in a loop
for i in range(5):
self.assertEqual(plus1(i), i + 1)
class TestCube(unittest.TestCase):
def test_cube(self):
# can generate tests in a loop
for i in range(5):
self.assertEqual(mypack.functions.cube(i), i**3)
class TestMyClass(unittest.TestCase):
def setUp(self):
self.a = 5
self.b = 4
self.obj = myclass(self.a, self.b)
def test_a(self):
self.assertEqual(self.obj.a, self.a)
def test_b(self):
# self.assertEqual(self.obj.b, self.a)
self.assertEqual(self.obj.b, self.b)