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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/usr/bin/python
#
# Runs all tests in the current directory
#
# Execute like:
# python runalltests.py
#
# Alternatively use the testrunner:
# python /path/to/Zope/utilities/testrunner.py -qa
#
import os, sys
import unittest
import doctest
from pkg_resources import resource_filename
import logging
logging.basicConfig(level=logging.WARN,
format="%(asctime)-15s %(name)s %(levelname)s: %(message)s",
stream=sys.stderr)
doctests = [
resource_filename(__name__, "xapianindex.txt"),
resource_filename(__name__, "milestone_1.txt"),
resource_filename(__name__, "sugar_demo_may17.txt"),
resource_filename(__name__, "milestone_2.txt"),
resource_filename(__name__, "mountpoints.txt"),
resource_filename(__name__, "properties.txt"),
resource_filename(__name__, "dateranges.txt"),
]
doctest_options = doctest.ELLIPSIS
doctest_options |= doctest.REPORT_ONLY_FIRST_FAILURE
def test_suite():
global doctests
suite = unittest.TestSuite()
if len(sys.argv) > 1:
doctests = sys.argv[1:]
for dt in doctests:
suite.addTest(doctest.DocFileSuite(dt,
optionflags=doctest_options))
if len(sys.argv) <= 1:
tests = os.listdir(os.curdir)
tests = [n[:-3] for n in tests if n.startswith('test') and
n.endswith('.py')]
for test in tests:
m = __import__(test)
if hasattr(m, 'test_suite'):
suite.addTest(m.test_suite())
return suite
if __name__ == "__main__":
runner = unittest.TextTestRunner(verbosity=1)
suite = test_suite()
runner.run(suite)
|