33 |
|
|
34 |
import unittest, os.path, fnmatch, string, imp |
import unittest, os.path, fnmatch, string, imp |
35 |
|
|
36 |
def tests(dir): |
def tests(files): |
37 |
""" |
""" |
38 |
Return a list of all *.test files in a given directory and its |
Return a list of all *.test files in a given directory and its |
39 |
subdirectories. |
subdirectories. |
45 |
list.extend(names) |
list.extend(names) |
46 |
|
|
47 |
tests = [] |
tests = [] |
48 |
os.path.walk(dir, addTests, tests) |
for f in files: |
49 |
|
if os.path.isdir(f): |
50 |
|
os.path.walk(f, addTests, tests) |
51 |
|
else: |
52 |
|
tests.append(f) |
53 |
return tests |
return tests |
54 |
|
|
55 |
faildefs = compile(""" |
faildefs = compile(""" |
110 |
|
|
111 |
|
|
112 |
|
|
113 |
def suite(dir): |
def suite(files): |
114 |
"""Create a test suite for all .tests in a given directory.""" |
"""Create a test suite for all .tests in a given directory.""" |
115 |
return unittest.TestSuite([unittest.makeSuite(load(t)) |
return unittest.TestSuite([unittest.makeSuite(load(t)) |
116 |
for t in tests(dir)]) |
for t in tests(files)]) |
117 |
|
|
118 |
|
|
119 |
if __name__ == '__main__': |
if __name__ == '__main__': |
120 |
unittest.TextTestRunner(verbosity=2).run(suite('test/')) |
import sys |
121 |
|
test = ['test/'] |
122 |
|
if len(sys.argv) > 1: |
123 |
|
test = sys.argv[1:] |
124 |
|
unittest.TextTestRunner(verbosity=2).run(suite(test)) |
125 |
|
|