15 |
# $Source$ |
# $Source$ |
16 |
# $Id$ |
# $Id$ |
17 |
|
|
18 |
import os, sys |
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 |
import warnings |
31 |
import unittest |
import unittest |
32 |
|
import getopt |
33 |
|
|
34 |
import support |
import support |
35 |
support.initthuban() |
support.initthuban() |
57 |
warnings.filterwarnings("error", ".*old table interface.*", |
warnings.filterwarnings("error", ".*old table interface.*", |
58 |
DeprecationWarning) |
DeprecationWarning) |
59 |
|
|
60 |
|
verbosity = 1 |
61 |
|
|
62 |
|
opts, args = getopt.getopt(sys.argv[1:], 'v', ['verbose']) |
63 |
|
for optchar, value in opts: |
64 |
|
if optchar in ("-v", "--verbose"): |
65 |
|
verbosity = 2 |
66 |
|
else: |
67 |
|
print>>sys.stderr, "Unknown option", optchar |
68 |
|
|
69 |
# All Python files starting with test in the current directory |
# All Python files starting with test in the current directory |
70 |
# contain test cases. |
# contain test cases. |
71 |
# FIXME: It should be possible to run runtests.py even when not in |
# FIXME: It should be possible to run runtests.py even when not in |
72 |
# the test directory |
# the test directory |
73 |
files = os.listdir(os.curdir) |
files = os.listdir(os.curdir) |
74 |
names = [] |
if args: |
75 |
for file in files: |
names = args |
76 |
if file[:4] == "test" and file[-3:] == ".py": |
else: |
77 |
names.append(file[:-3]) |
names = [] |
78 |
|
for file in files: |
79 |
|
if file[:4] == "test" and file[-3:] == ".py": |
80 |
|
names.append(file[:-3]) |
81 |
|
|
82 |
suite = unittest.defaultTestLoader.loadTestsFromNames(names) |
suite = unittest.defaultTestLoader.loadTestsFromNames(names) |
83 |
runner = unittest.TextTestRunner(verbosity = 2) |
runner = support.ThubanTestRunner(verbosity = verbosity) |
84 |
result = runner.run(suite) |
result = support.execute_as_testsuite(runner.run, suite) |
|
|
|
|
support.print_additional_summary() |
|
85 |
|
|
86 |
sys.exit(not result.wasSuccessful()) |
sys.exit(not result.wasSuccessful()) |
87 |
|
|