2 ''''exec python
-u "$0" "$@" #'''
5 # Author: David Goodger <goodger@python.org>
6 # 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.
23 import DocutilsTestSupport
# must be imported before docutils
29 """Write to a file and a stream (default: stdout) simultaneously."""
31 def __init__
(self
, filename
, stream
=sys.__stdout__
):
32 self.
file = open
(filename
, 'w')
34 self.encoding
= getattr
(stream
, 'encoding', None
)
36 def
write(self
, string
):
38 self.stream.
write(string
)
39 self.
file.
write(string
)
40 except UnicodeEncodeError
: # Py3k writing to "ascii" stream/file
41 string
= string.encode
('raw_unicode_escape').decode
('ascii')
42 self.stream.
write(string
)
43 self.
file.
write(string
)
52 suitestr
= repr
(suite
).replace
('=[<', '=[\n<').replace
(', ', ',\n')
55 for line
in suitestr.splitlines
():
56 output.append
(' ' * indent
+ line
)
60 if line
[-5:] == ']>]>,':
62 elif line
[-3:] == ']>,':
64 return '\n'.
join(output
)
67 path
, script = os.path.
split(sys.argv
[0])
68 suite
= package_unittest.loadTestModules
(DocutilsTestSupport.testroot
,
73 # must redirect stderr *before* first import of unittest
74 sys.stdout
= sys.stderr
= Tee
('alltests.out')
76 import package_unittest
79 if __name__
== '__main__':
81 print
('Testing Docutils %s [%s] with Python %s on %s at %s'
82 % (docutils.__version__
, docutils.__version_details__
,
83 sys.version.
split()[0],
84 time.strftime
('%Y-%m-%d'), time.strftime
('%H:%M:%S')))
85 print
('OS: %s %s %s (%s, %s)'
86 % (platform.system
(), platform.release
(), platform.version
(),
87 sys.platform
, platform.platform
()))
88 print
'Working directory: %s' % os.getcwd
()
89 print
'Docutils package: %s' % os.path.
dirname(docutils.__file__
)
91 result
= package_unittest.main
(suite
)
92 #if package_unittest.verbosity > 1:
93 # print >>sys.stderr, pformat(suite) # check the test suite
95 print
'Elapsed time: %.3f seconds' % (finish
- start
)
96 sys.
exit(not result.wasSuccessful
())