~ubuntu-branches/ubuntu/lucid/thuban/lucid

« back to all changes in this revision

Viewing changes to test/runtests.py

  • Committer: Bazaar Package Importer
  • Author(s): Silke Reimer
  • Date: 2004-01-28 12:47:34 UTC
  • Revision ID: james.westby@ubuntu.com-20040128124734-6xotwcqilok6ngut
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2002, 2003 by Intevation GmbH
 
2
# Authors:
 
3
# Bernhard Herzog <bh@intevation.de>
 
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: 1.13 $"
 
15
# $Source: /thubanrepository/thuban/test/runtests.py,v $
 
16
# $Id: runtests.py,v 1.13 2003/11/19 15:46:22 bh Exp $
 
17
 
 
18
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
import warnings
 
31
import unittest
 
32
import getopt
 
33
 
 
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
    # 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
    verbosity = 1
 
54
 
 
55
    opts, args = getopt.getopt(sys.argv[1:], 'v', ['verbose'])
 
56
    for optchar, value in opts:
 
57
        if optchar in ("-v", "--verbose"):
 
58
            verbosity = 2
 
59
        else:
 
60
            print>>sys.stderr, "Unknown option", optchar
 
61
 
 
62
    # All Python files starting with test in the current directory
 
63
    # contain test cases.
 
64
    # FIXME: It should be possible to run runtests.py even when not in
 
65
    # the test directory
 
66
    files = os.listdir(os.curdir)
 
67
    if args:
 
68
        names = args
 
69
    else:
 
70
        names = []
 
71
        for file in files:
 
72
            if file[:4] == "test" and file[-3:] == ".py":
 
73
                names.append(file[:-3])
 
74
 
 
75
    suite = unittest.defaultTestLoader.loadTestsFromNames(names)
 
76
    runner = support.ThubanTestRunner(verbosity = verbosity)
 
77
    result = support.execute_as_testsuite(runner.run, suite)
 
78
 
 
79
    sys.exit(not result.wasSuccessful())
 
80
 
 
81
 
 
82
if __name__ == "__main__":
 
83
    main()