1 |
# Copyright (c) 2002, 2003 by Intevation GmbH |
2 |
# 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 |
__version__ = "$Revision$" |
15 |
# $Source$ |
16 |
# $Id$ |
17 |
|
18 |
import os, sys |
19 |
import warnings |
20 |
import unittest |
21 |
|
22 |
import support |
23 |
support.initthuban() |
24 |
import Thuban.Lib.connector |
25 |
|
26 |
def main(): |
27 |
"""Run all the tests in the Thuban test suite""" |
28 |
|
29 |
# Turn Thuban's deprecation warnings into errors so they're cought |
30 |
# by the tests |
31 |
# |
32 |
# Maintenance: Keep a warning filter until the backwards |
33 |
# compatibility code is removed at which time using the old |
34 |
# interfaces should lead to other errors anyway. |
35 |
|
36 |
# The layer attributes table, shapetable, shapefile and filename are |
37 |
# deprecated. |
38 |
warnings.filterwarnings("error", "The Layer attribute.*is deprecated", |
39 |
DeprecationWarning) |
40 |
|
41 |
# Usage of the old table interface. This old interface is still used |
42 |
# by the test_table.py module which calls filterwarnings too to |
43 |
# ignore the warnings issued by its own intended use of the old |
44 |
# interface. |
45 |
warnings.filterwarnings("error", ".*old table interface.*", |
46 |
DeprecationWarning) |
47 |
|
48 |
|
49 |
# All Python files starting with test in the current directory |
50 |
# contain test cases. |
51 |
# FIXME: It should be possible to run runtests.py even when not in |
52 |
# the test directory |
53 |
files = os.listdir(os.curdir) |
54 |
names = [] |
55 |
for file in files: |
56 |
if file[:4] == "test" and file[-3:] == ".py": |
57 |
names.append(file[:-3]) |
58 |
|
59 |
suite = unittest.defaultTestLoader.loadTestsFromNames(names) |
60 |
runner = unittest.TextTestRunner(verbosity = 2) |
61 |
result = runner.run(suite) |
62 |
|
63 |
support.print_additional_summary() |
64 |
|
65 |
sys.exit(not result.wasSuccessful()) |
66 |
|
67 |
|
68 |
if __name__ == "__main__": |
69 |
main() |