3 # Author: David Goodger
4 # Contact: goodger@users.sourceforge.net
7 # Copyright: This module has been placed in the public domain.
10 All modules named 'test_*.py' in the current directory, and recursively in
11 subdirectories (packages) called 'test_*', are loaded and test suites within
16 # Start point for actual elapsed time, including imports
17 # and setup outside of unittest.
27 """Write to a file and a stream (default: stdout) simultaneously."""
29 def __init__(self
, filename
, stream
=sys
.__stdout
__):
30 self
.file = open(filename
, 'w')
33 def write(self
, string
):
34 self
.stream
.write(string
)
35 self
.file.write(string
)
44 suitestr
= repr(suite
).replace('=[<', '=[\n<').replace(', ', ',\n')
47 for line
in suitestr
.splitlines():
48 output
.append(' ' * indent
+ line
)
52 if line
[-5:] == ']>]>,':
54 elif line
[-3:] == ']>,':
56 return '\n'.join(output
)
59 # must redirect stderr *before* first import of unittest
60 sys
.stdout
= sys
.stderr
= Tee('alltests.out')
62 import package_unittest
64 print ('Testing Docutils %s with Python %s'
65 % (docutils
.__version
__, sys
.version
.split()[0]))
67 path
, script
= os
.path
.split(sys
.argv
[0])
68 suite
= package_unittest
.loadTestModules(path
, 'test_', packages
=1)
69 package_unittest
.main(suite
)
70 #if package_unittest.verbosity > 1:
71 # print >>sys.stderr, pformat(suite) # check the test suite
74 print 'Elapsed time: %.3f seconds' % (finish
- start
)