1 |
# Copyright (c) 2002, 2003 by Intevation GmbH |
# Copyright (c) 2002, 2003, 2004, 2005 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
4 |
# |
# |
48 |
""" |
""" |
49 |
global _initthuban_done |
global _initthuban_done |
50 |
if not _initthuban_done: |
if not _initthuban_done: |
51 |
|
# Thuban uses gettext to translate some strings. Some of these |
52 |
|
# strings are tested for equality in some test cases. So we |
53 |
|
# unset any LANG environment setting to make sure only the |
54 |
|
# untranslated messages are used. |
55 |
|
try: |
56 |
|
del os.environ["LANG"] |
57 |
|
except KeyError: |
58 |
|
pass |
59 |
add_thuban_dir_to_path() |
add_thuban_dir_to_path() |
60 |
import thubaninit |
import thubaninit |
61 |
|
|
62 |
|
# Install a dummy translation function so that importing |
63 |
|
# Thuban.UI doesn't install a wx specific one for which would |
64 |
|
# need to import wxPython |
65 |
|
import Thuban |
66 |
|
Thuban.install_translation_function(lambda s: s) |
67 |
|
|
68 |
|
# For the time being the default encoding in the test suite is |
69 |
|
# latin 1. This is mostly for historical reasons. Other |
70 |
|
# encodings can be specified as an argument for runtests.py. |
71 |
|
Thuban.set_internal_encoding("latin-1") |
72 |
|
|
73 |
_initthuban_done = 1 |
_initthuban_done = 1 |
74 |
|
|
75 |
|
|
127 |
self.stream.writeln(" " + test.id()) |
self.stream.writeln(" " + test.id()) |
128 |
unittest._TextTestResult.printErrors(self) |
unittest._TextTestResult.printErrors(self) |
129 |
|
|
130 |
|
def getDescription(self, test): |
131 |
|
return test.id() |
132 |
|
|
133 |
|
|
134 |
class ThubanTestRunner(unittest.TextTestRunner): |
class ThubanTestRunner(unittest.TextTestRunner): |
135 |
|
|
146 |
|
|
147 |
def runTests(self): |
def runTests(self): |
148 |
"""Extend inherited method so that we use a ThubanTestRunner""" |
"""Extend inherited method so that we use a ThubanTestRunner""" |
|
print "ThubanTestProgram.runTests" |
|
149 |
self.testRunner = ThubanTestRunner(verbosity = self.verbosity) |
self.testRunner = ThubanTestRunner(verbosity = self.verbosity) |
150 |
unittest.TestProgram.runTests(self) |
unittest.TestProgram.runTests(self) |
151 |
|
|
203 |
Run the garbage collector and print uncollected objects. Also print |
Run the garbage collector and print uncollected objects. Also print |
204 |
any un-unsubscribed messages. |
any un-unsubscribed messages. |
205 |
""" |
""" |
206 |
|
# this function may be called indirectly from test cases that test |
207 |
|
# test support modules which do not use anything from thuban itself, |
208 |
|
# so we call initthuban so that we can import the connector module |
209 |
|
initthuban() |
210 |
import gc, Thuban.Lib.connector |
import gc, Thuban.Lib.connector |
211 |
gc.collect() |
gc.collect() |
212 |
if gc.garbage: |
if gc.garbage: |
273 |
def filename(self): |
def filename(self): |
274 |
"""Return the name of the test file to use. |
"""Return the name of the test file to use. |
275 |
|
|
276 |
The default implementation simply calls self.volatile_file_name |
The default implementation simply calls self.temp_file_name with |
277 |
with a basename derived from the class name by stripping off a |
a basename derived from the class name by stripping off a |
278 |
leading 'test_' and appending self.file_extension. |
leading 'test_' and appending self.file_extension. |
279 |
""" |
""" |
280 |
name = self.__class__.__name__ |
name = self.__class__.__name__ |
327 |
value in test and value is less than the optional parameter |
value in test and value is less than the optional parameter |
328 |
epsilon. If epsilon is not given use self.fp_epsilon. |
epsilon. If epsilon is not given use self.fp_epsilon. |
329 |
""" |
""" |
330 |
|
self.assertEquals(len(test), len(value)) |
331 |
for i in range(len(test)): |
for i in range(len(test)): |
332 |
self.assertFloatEqual(test[i], value[i], epsilon) |
self.assertFloatEqual(test[i], value[i], epsilon) |
333 |
|
|