2 ''''exec python
-u "$0" "$@" #'''
4 # Author: David Goodger
5 # Contact: goodger@users.sourceforge.net
8 # Copyright: This module has been placed in the public domain.
12 All modules named 'test_*.py' in the current directory, and recursively in
13 subdirectories (packages) called 'test_*', are loaded and test suites within
18 # Start point for actual elapsed time, including imports
19 # and setup outside of unittest.
24 from types import UnicodeType
28 def new_exception_str
(self
):
30 if isinstance
(i
, UnicodeType
):
31 raise RuntimeError
('Error (unicode): %r' % (self.args
,))
32 return old_exception_str
(self
)
34 old_exception_str
= Exception.__str__
35 Exception.__str__
= new_exception_str
40 """Write to a file and a stream (default: stdout) simultaneously."""
42 def __init__
(self
, filename
, stream
=sys.__stdout__
):
43 self.
file = open
(filename
, 'w')
46 def
write(self
, string
):
47 self.stream.
write(string
)
48 self.
file.
write(string
)
57 suitestr
= repr
(suite
).replace
('=[<', '=[\n<').replace
(', ', ',\n')
60 for line
in suitestr.splitlines
():
61 output.append
(' ' * indent
+ line
)
65 if line
[-5:] == ']>]>,':
67 elif line
[-3:] == ']>,':
69 return '\n'.
join(output
)
72 # must redirect stderr *before* first import of unittest
73 sys.stdout
= sys.stderr
= Tee
('alltests.out')
75 import package_unittest
77 print
('Testing Docutils %s [%s] with Python %s on %s at %s'
78 % (docutils.__version__
, docutils.__version_details__
,
79 sys.version.
split()[0],
80 time.strftime
('%Y-%m-%d'), time.strftime
('%H:%M:%S')))
83 path
, script = os.path.
split(sys.argv
[0])
84 suite
= package_unittest.loadTestModules
(path
, 'test_', packages
=1)
87 package_unittest.main
(suite
)
88 #if package_unittest.verbosity > 1:
89 # print >>sys.stderr, pformat(suite) # check the test suite
92 print
'Elapsed time: %.3f seconds' % (finish
- start
)