forked from wo1fsea/PyTexturePacker
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
37 lines (27 loc) · 997 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
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
"""----------------------------------------------------------------------------
Author:
Huang Quanyong (wo1fSea)
Date:
2016/11/06
Description:
test.py
----------------------------------------------------------------------------"""
import unittest
TEST_MODULE = "tests"
TEST_CASE_NAME = "^test[\w]+\.py$"
def load_test_suite():
import unittest
import re
import os
test_path = os.path.abspath(TEST_MODULE)
files = os.listdir(test_path)
test_file_re = re.compile(TEST_CASE_NAME, re.IGNORECASE)
files = filter(test_file_re.match, files)
module_names = map(lambda f: os.path.splitext(f)[0], files)
modules = map(lambda x: __import__("%s.%s" % (TEST_MODULE, x), fromlist=[TEST_MODULE]), module_names)
return unittest.TestSuite(map(unittest.defaultTestLoader.loadTestsFromModule, modules))
if __name__ == '__main__':
a = load_test_suite()
unittest.main(defaultTest="load_test_suite")