latex2e writer : Move usepackage hyperref after stylesheet inclusion.
[docutils.git] / test / alltests.py
blobb342f6104a81cd47e74d41fe1bd8288eac2b7989
1 #!/bin/sh
2 ''''exec python -u "$0" "$@" #'''
4 # $Id$
5 # Author: David Goodger <goodger@python.org>
6 # Copyright: This module has been placed in the public domain.
8 __doc__ = \
9 """
10 All modules named 'test_*.py' in the current directory, and recursively in
11 subdirectories (packages) called 'test_*', are loaded and test suites within
12 are run.
13 """
15 import time
16 # Start point for actual elapsed time, including imports
17 # and setup outside of unittest.
18 start = time.time()
20 import sys
21 import os
22 import DocutilsTestSupport # must be imported before docutils
23 import docutils
26 class Tee:
28 """Write to a file and a stream (default: stdout) simultaneously."""
30 def __init__(self, filename, stream=sys.__stdout__):
31 self.file = open(filename, 'w')
32 self.stream = stream
34 def write(self, string):
35 self.stream.write(string)
36 self.file.write(string)
38 def flush(self):
39 self.stream.flush()
40 self.file.flush()
43 def pformat(suite):
44 step = 4
45 suitestr = repr(suite).replace('=[<', '=[\n<').replace(', ', ',\n')
46 indent = 0
47 output = []
48 for line in suitestr.splitlines():
49 output.append(' ' * indent + line)
50 if line[-1:] == '[':
51 indent += step
52 else:
53 if line [-5:] == ']>]>,':
54 indent -= step * 2
55 elif line[-3:] == ']>,':
56 indent -= step
57 return '\n'.join(output)
59 def suite():
60 path, script = os.path.split(sys.argv[0])
61 suite = package_unittest.loadTestModules(DocutilsTestSupport.testroot,
62 'test_', packages=1)
63 sys.stdout.flush()
64 return suite
66 # must redirect stderr *before* first import of unittest
67 sys.stdout = sys.stderr = Tee('alltests.out')
69 import package_unittest
72 if __name__ == '__main__':
73 suite = suite()
74 print ('Testing Docutils %s [%s] with Python %s on %s at %s'
75 % (docutils.__version__, docutils.__version_details__,
76 sys.version.split()[0],
77 time.strftime('%Y-%m-%d'), time.strftime('%H:%M:%S')))
78 print 'Working directory: %s' % os.getcwd()
79 print 'Docutils package: %s' % os.path.dirname(docutils.__file__)
80 sys.stdout.flush()
81 package_unittest.main(suite)
82 #if package_unittest.verbosity > 1:
83 # print >>sys.stderr, pformat(suite) # check the test suite
84 finish = time.time()
85 print 'Elapsed time: %.3f seconds' % (finish - start)