/[thuban]/branches/WIP-pyshapelib-bramz/test/runtests.py
ViewVC logotype

Contents of /branches/WIP-pyshapelib-bramz/test/runtests.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2642 - (show annotations)
Fri Jul 1 20:49:04 2005 UTC (19 years, 8 months ago) by bh
Original Path: trunk/thuban/test/runtests.py
File MIME type: text/x-python
File size: 3599 byte(s)
First step towards unicode.  With this roughly we're at step 1
string_representation.txt

* Doc/technotes/string_representation.txt: New.  Document how
strings are represented in Thuban and how to get to a Unicode
Thuban.

* Thuban/__init__.py (set_internal_encoding)
(unicode_from_internal, internal_from_unicode): New. The first few
functions for the internal string representation

* Thuban/UI/about.py (unicodeToLocale): Removed.  Use
internal_from_unicode instead.

* Thuban/UI/__init__.py (install_wx_translation): Determine the
encoding to use for the internal string representation.  Also,
change the translation function to return strings in internal
representation even on unicode builds of wxPython

* Thuban/Model/load.py (SessionLoader.check_attrs): Decode
filenames too.
(SessionLoader.start_clrange): Use check_attrs to decode and check
the attributes.

* Thuban/Model/xmlreader.py (XMLReader.encode): Use
internal_from_unicode to convert unicode strings.

* Thuban/Model/xmlwriter.py (XMLWriter.encode): Use
unicode_from_internal when applicable

* test/runtests.py (main): New command line option:
internal-encoding to specify the internal string encoding to use
in the tests.

* test/support.py (initthuban): Set the internal encoding to
latin-1

* test/test_load.py (TestSingleLayer.test, TestClassification.test)
(TestLabelLayer.test): Use the internal string representation when
dealing with non-ascii characters

* test/test_load_1_0.py (TestSingleLayer.test)
(TestClassification.test, TestLabelLayer.test): Use the internal
string representation when dealing with non-ascii characters

* test/test_load_0_9.py (TestSingleLayer.test)
(TestClassification.test): Use the internal string representation
when dealing with non-ascii characters

* test/test_load_0_8.py (TestUnicodeStrings.test): Use the
internal string representation when dealing with non-ascii
characters

* test/test_save.py (XMLWriterTest.testEncode)
(SaveSessionTest.testClassifiedLayer): Use the internal string
representation when dealing with non-ascii characters where
applicable

1 # Copyright (c) 2002, 2003, 2004, 2005 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
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 find_test_modules(dirname, package = None):
39 """Return a list the names of the test modules in the directory dirname
40
41 The return value is a list of names that can be passed to
42 unittest.defaultTestLoader.loadTestsFromNames. Each name of the
43 list is the name of a pure python module, one for each file in
44 dirname that starts with 'test'.
45
46 The optional parameter package should be the name of the python
47 package whose directory is dirname. If package is given all names
48 in the returned list will be prefixed with package and a dot.
49 """
50 if package:
51 prefix = package + "."
52 else:
53 prefix = ""
54
55 return [prefix + name[:-3]
56 for name in os.listdir(dirname)
57 if name[:4] == "test" and name[-3:] == ".py"]
58
59
60 def main():
61 """Run all the tests in the Thuban test suite"""
62
63 # Turn Thuban's deprecation warnings into errors so they're cought
64 # by the tests
65 #
66 # Maintenance: Keep a warning filter until the backwards
67 # compatibility code is removed at which time using the old
68 # interfaces should lead to other errors anyway.
69
70 # The layer attributes table, shapetable, shapefile and filename are
71 # deprecated.
72 warnings.filterwarnings("error", "The Layer attribute.*is deprecated",
73 DeprecationWarning)
74
75 verbosity = 1
76
77 opts, args = getopt.getopt(sys.argv[1:], 'v',
78 ['verbose', "internal-encoding="])
79 for optchar, value in opts:
80 if optchar in ("-v", "--verbose"):
81 verbosity = 2
82 elif optchar == "--internal-encoding":
83 Thuban.set_internal_encoding(value)
84 else:
85 print>>sys.stderr, "Unknown option", optchar
86
87 # Build the list of test names. If names were given on the command
88 # line, run exactly those. Othwerwise build a default list of
89 # names.
90 if args:
91 names = args
92 else:
93 # All Python files starting with 'test' in the current directory
94 # and some directories in Extensions contain test cases.
95 # FIXME: It should be possible to run runtests.py even when not in
96 # the test directory
97 names = find_test_modules(".")
98 names += find_test_modules("../Extensions/svgexport/test",
99 "Extensions.svgexport.test")
100 names += find_test_modules("../Extensions/ogr/test",
101 "Extensions.ogr.test")
102 suite = unittest.defaultTestLoader.loadTestsFromNames(names)
103 runner = support.ThubanTestRunner(verbosity = verbosity)
104 result = support.execute_as_testsuite(runner.run, suite)
105
106 sys.exit(not result.wasSuccessful())
107
108
109 if __name__ == "__main__":
110 main()

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26