forked from alexazhou/VeryNginx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
40 lines (29 loc) · 1.03 KB
/
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2016-08-21 23:06
# @Author : Alexa ([email protected])
# @Link : https://github.com/alexazhou/VeryNginx
# @Disc : test VeryNginx
# @Disc : support python 3.x
import os
import time
import unittest
def load_test_case():
ret = {}
dir_filter = lambda x:os.path.exists( './testcase/' + x + '/case.py' )
case_list = list(filter( dir_filter, os.listdir('./testcase/') ))
for case in case_list:
tmp = __import__( 'testcase.%s.case'%case )
ret[case] = eval( 'tmp.%s.case'%case )
return ret
if __name__ == "__main__":
script_path = os.path.dirname( os.path.abspath(__file__) )
os.chdir( script_path )
all_case = load_test_case()
major_suite = unittest.TestSuite()
for k in all_case.keys():
suite = unittest.defaultTestLoader.loadTestsFromTestCase(all_case[k].Case)
major_suite.addTests( suite )
runner = unittest.TextTestRunner()
ret = runner.run(major_suite)
assert ret.wasSuccessful()