1 |
bh |
597 |
# Copyright (c) 2002, 2003 by Intevation GmbH |
2 |
bh |
292 |
# Authors: |
3 |
|
|
# Bernhard Herzog <[email protected]> |
4 |
|
|
# |
5 |
|
|
# This program is free software under the GPL (>=v2) |
6 |
|
|
# Read the file COPYING coming with Thuban for details. |
7 |
|
|
|
8 |
|
|
""" |
9 |
|
|
Main entry point for the Thuban test suite. |
10 |
|
|
|
11 |
|
|
Just run this file as a python script to execute all tests |
12 |
|
|
""" |
13 |
|
|
|
14 |
bh |
1269 |
__version__ = "$Revision$" |
15 |
|
|
# $Source$ |
16 |
|
|
# $Id$ |
17 |
bh |
292 |
|
18 |
bh |
1458 |
import os |
19 |
|
|
|
20 |
|
|
# It should be possible to run the Thuban testsuite without an X |
21 |
|
|
# connection, so we remove the DISPLAY environment variable which should |
22 |
|
|
# lead to an error if the wxGTK module is imported accidentally. The |
23 |
|
|
# DISPLAY variable is not always set so we catch and ignore the KeyError |
24 |
|
|
try: |
25 |
|
|
del os.environ["DISPLAY"] |
26 |
|
|
except KeyError: |
27 |
|
|
pass |
28 |
|
|
|
29 |
|
|
import sys |
30 |
bh |
1219 |
import warnings |
31 |
bh |
292 |
import unittest |
32 |
bh |
1377 |
import getopt |
33 |
bh |
292 |
|
34 |
|
|
import support |
35 |
|
|
support.initthuban() |
36 |
|
|
import Thuban.Lib.connector |
37 |
|
|
|
38 |
|
|
def main(): |
39 |
|
|
"""Run all the tests in the Thuban test suite""" |
40 |
|
|
|
41 |
bh |
1219 |
# Turn Thuban's deprecation warnings into errors so they're cought |
42 |
|
|
# by the tests |
43 |
|
|
# |
44 |
|
|
# Maintenance: Keep a warning filter until the backwards |
45 |
|
|
# compatibility code is removed at which time using the old |
46 |
|
|
# interfaces should lead to other errors anyway. |
47 |
|
|
|
48 |
|
|
# The layer attributes table, shapetable, shapefile and filename are |
49 |
|
|
# deprecated. |
50 |
|
|
warnings.filterwarnings("error", "The Layer attribute.*is deprecated", |
51 |
|
|
DeprecationWarning) |
52 |
|
|
|
53 |
|
|
# Usage of the old table interface. This old interface is still used |
54 |
|
|
# by the test_table.py module which calls filterwarnings too to |
55 |
|
|
# ignore the warnings issued by its own intended use of the old |
56 |
|
|
# interface. |
57 |
|
|
warnings.filterwarnings("error", ".*old table interface.*", |
58 |
|
|
DeprecationWarning) |
59 |
|
|
|
60 |
bh |
1377 |
verbosity = 1 |
61 |
bh |
1219 |
|
62 |
bh |
1377 |
opts, args = getopt.getopt(sys.argv[1:], 'v', ['verbose']) |
63 |
|
|
for optchar, value in opts: |
64 |
|
|
if optchar in ("-v", "--stub-auto-login"): |
65 |
|
|
verbosity = 2 |
66 |
jonathan |
1396 |
else: |
67 |
|
|
print>>sys.stderr, "Unknown option", optchar |
68 |
bh |
1377 |
|
69 |
bh |
1219 |
# All Python files starting with test in the current directory |
70 |
|
|
# contain test cases. |
71 |
|
|
# FIXME: It should be possible to run runtests.py even when not in |
72 |
|
|
# the test directory |
73 |
bh |
292 |
files = os.listdir(os.curdir) |
74 |
|
|
names = [] |
75 |
|
|
for file in files: |
76 |
|
|
if file[:4] == "test" and file[-3:] == ".py": |
77 |
|
|
names.append(file[:-3]) |
78 |
|
|
|
79 |
|
|
suite = unittest.defaultTestLoader.loadTestsFromNames(names) |
80 |
bh |
1377 |
runner = unittest.TextTestRunner(verbosity = verbosity) |
81 |
bh |
292 |
result = runner.run(suite) |
82 |
|
|
|
83 |
bh |
1245 |
support.print_additional_summary() |
84 |
bh |
292 |
|
85 |
|
|
sys.exit(not result.wasSuccessful()) |
86 |
|
|
|
87 |
|
|
|
88 |
|
|
if __name__ == "__main__": |
89 |
|
|
main() |