Debian Codegraph @

run_tests.py

raw symbols SCIP
1 #!/usr/bin/env python
2
3 """
4 Note that the functional tests and doctests require test-tools to be on
5 sys.path before the stdlib. One way to ensure that is to use this script to
6 run tests.
7 """
8
9 import os
10 import sys
11
12
13 def mutate_sys_path():
14 this_dir = os.path.dirname(__file__)
15 sys.path.insert(0, os.path.join(this_dir, "test"))
16 sys.path.insert(0, os.path.join(this_dir, "test-tools"))
17 sys.path.insert(0, os.path.join(this_dir, "mechanize"))
18
19
20 def run_tests(test_names=()):
21 pass
22
23
24 def main(argv):
25 # test-tools/ dir includes a bundled Python 2.5 doctest / linecache, and a
26 # bundled & modified Python trunk (2.7 vintage) unittest. This is only for
27 # testing purposes, and these don't get installed.
28
29 # unittest revision 77209, modified (probably I should have used PyPI
30 # project discover, which is already backported to 2.4, but since I've
31 # already done that and made changes, I won't bother for now)
32
33 # doctest.py revision 45701 and linecache.py revision 45940. Since
34 # linecache is used by Python itself, linecache.py is renamed
35 # linecache_copy.py, and this copy of doctest is modified (only) to use
36 # that renamed module.
37
38 mutate_sys_path()
39 assert "doctest" not in sys.modules
40 import testprogram
41
42 # *.py to catch doctests in docstrings
43 this_dir = os.path.dirname(__file__)
44 prog = testprogram.TestProgram(
45 argv=argv, default_discovery_args=(this_dir, "*.py", None),
46 module=None)
47 result = prog.runTests()
48 success = result.wasSuccessful()
49 sys.exit(int(not success))
50
51
52 if __name__ == "__main__":
53 main(sys.argv)