-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path0409_unit_test.py
More file actions
34 lines (25 loc) · 883 Bytes
/
0409_unit_test.py
File metadata and controls
34 lines (25 loc) · 883 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
import unittest
import mock
import panduanchengji_0409
class TestTool(unittest.TestCase):
def setUp(self):
print "run setup before case"
def tearDown(self):
print "run tearDown after case"
@classmethod
def setUpClass(cls):
print "before class"
@classmethod
def tearDownClass(cls):
print "after class"
def test_tool_report_should_ok(self):
level = panduanchengji_0409.getLevel(85)
self.assertEquals(level, 'Good')
def test_query_db_should_ok(self):
panduanchengji_0409.connectDB = mock.Mock(return_value=[[1, 'alice', 23, 12], [2, 'wmsj100', 89, 99]])
stu_list = panduanchengji_0409.connectDB('select * from stu_score')
print stu_list
self.assertTrue(len(stu_list) == 2)
self.assertEqual(stu_list[1][3], 99)
if __name__ == "__main__":
unittest.main()