root/test.py

Revision 340:d47095a15b60, 2.5 kB (checked in by Stefan Schwarzer <sschwarzer@sschwarzer.net>, 5 months ago)
Removed unused import statements.
  • Property exe set to *
Line 
1 #! /usr/bin/env python
2 # Copyright (C) 2007, Stefan Schwarzer
3 #
4 # Permission is hereby granted, free of charge, to any person
5 # obtaining a copy of this software and associated documentation files
6 # (the "Software"), to deal in the Software without restriction,
7 # including without limitation the rights to use, copy, modify, merge,
8 # publish, distribute, sublicense, and/or sell copies of the Software,
9 # and to permit persons to whom the Software is furnished to do so,
10 # subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be
13 # included in all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 # SOFTWARE.
23
24 """
25 Run this file from the command line to have all doctests executed.
26 """
27
28 import doctest
29 import glob
30 import sys
31
32 # Websourcebrowser modules
33 # These aren't referenced explicitly below but they are searched
34 #  implicitly in the namespace of this module.
35 import coding
36 import config
37 import converter
38 import session
39 import urlpath
40
41
42 def main():
43     # tests in docstrings in modules
44     for item in globals().values():
45         if isinstance(item, type(doctest)) and \
46           item.__name__ not in ("__builtin__", "doctest"):
47             doctest.testmod(item)
48     # tests in text files
49     # compare http://www.velocityreviews.com/forums/showthread.php?t=363458&page=2
50     posixlike = """aix3 aix4 atheos beos5 darwin freebsd2 freebsd3 freebsd4
51                    freebsd5 freebsd6 freebsd7 generic irix5 irix6 linux2
52                    netbsd1 next3 os2emx riscos sunos5 unixware7""".split()
53     skip_under_posix = glob.glob("test_*_windows.txt")
54     skip_under_windows = glob.glob("test_*_posix.txt")
55     for file_name in glob.glob("test_*.txt"):
56         if sys.platform.startswith('win') and (file_name in skip_under_windows):
57             continue
58         if sys.platform in posixlike and (file_name in skip_under_posix):
59             continue
60         doctest.testfile(file_name)
61
62 if __name__ == '__main__':
63     # execute just the single test file if given on the command line
64     if len(sys.argv) == 2:
65         doctest.testfile(sys.argv[1])
66     else:
67         main()
68
Note: See TracBrowser for help on using the browser.