bh: thuban/test test_save.py, 1.36, 1.37 test_load_1_0.py, 1.1, 1.2 test_load_0_9.py, 1.3, 1.4 test_load_0_8.py, 1.4, 1.5 test_load.py, 1.46, 1.47 support.py, 1.20, 1.21 runtests.py, 1.16, 1.17

cvs@intevation.de cvs at intevation.de
Fri Jul 1 22:49:06 CEST 2005


Author: bh

Update of /thubanrepository/thuban/test
In directory doto:/tmp/cvs-serv11857/test

Modified Files:
	test_save.py test_load_1_0.py test_load_0_9.py 
	test_load_0_8.py test_load.py support.py runtests.py 
Log Message:
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


Index: test_save.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_save.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- test_save.py	6 May 2005 14:19:40 -0000	1.36
+++ test_save.py	1 Jul 2005 20:49:04 -0000	1.37
@@ -1,4 +1,4 @@
-# Copyright (c) 2002, 2003, 2004 by Intevation GmbH
+# Copyright (c) 2002, 2003, 2004, 2005 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh at intevation.de>
 #
@@ -25,6 +25,7 @@
 
 import dbflib
 
+from Thuban import internal_from_unicode
 from Thuban.Lib.fileutil import relative_filename
 from Thuban.Model.save import XMLWriter, save_session, sort_data_stores
 from Thuban.Model.session import Session
@@ -53,9 +54,9 @@
         eq(writer.encode("hello world"), "hello world")
         eq(writer.encode(unicode("hello world")), unicode("hello world"))
 
-        eq(writer.encode("\x80\x90\xc2\x100"), 
+        eq(writer.encode(internal_from_unicode(u"\x80\x90\xc2\x100")),
                          "\xc2\x80\xc2\x90\xc3\x82\x100")
-        eq(writer.encode(u"\x80\x90\xc2\x100"), 
+        eq(writer.encode(u"\x80\x90\xc2\x100"),
                          "\xc2\x80\xc2\x90\xc3\x82\x100")
         eq(writer.encode(u"\xFF5E"), "\xc3\xbf5E")
 
@@ -325,9 +326,10 @@
         layer2.SetClassificationColumn("POPYCOUN")
 
         # Classification with Latin 1 text
-        clazz.AppendGroup(ClassGroupSingleton('\xe4\xf6\xfc', # ae, oe, ue
-                                              ClassGroupProperties(),
-                                              '\xdcml\xe4uts')) # Uemlaeuts
+        clazz.AppendGroup(ClassGroupSingleton(
+            internal_from_unicode(u'\xe4\xf6\xfc'), # ae, oe, ue
+            ClassGroupProperties(),
+            internal_from_unicode(u'\xdcml\xe4uts'))) # Uemlaeuts
 
 
         filename = self.temp_file_name("%s.thuban" % self.id())

Index: test_load_1_0.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_load_1_0.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- test_load_1_0.py	12 Mar 2004 12:19:15 -0000	1.1
+++ test_load_1_0.py	1 Jul 2005 20:49:04 -0000	1.2
@@ -1,4 +1,4 @@
-# Copyright (c) 2002, 2003, 2004 by Intevation GmbH
+# Copyright (c) 2002, 2003, 2004, 2005 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh at intevation.de>
 #
@@ -27,6 +27,7 @@
 import dbflib
 import shapelib
 
+from Thuban import internal_from_unicode
 from Thuban.Model.save import save_session
 from Thuban.Model.load import load_session, parse_color, LoadError, \
      LoadCancelled
@@ -179,7 +180,7 @@
         self.session = session
 
         # Check the title
-        eq(session.Title(), "Stra\xdfen & Landmarken")
+        eq(session.Title(), internal_from_unicode(u"Stra\xdfen & Landmarken"))
 
         # the session has one map.
         maps = session.Maps()
@@ -187,7 +188,7 @@
 
         # Check the map's attributes
         map = maps[0]
-        eq(map.Title(), "\xdcbersicht")
+        eq(map.Title(), internal_from_unicode(u"\xdcbersicht"))
         proj = map.GetProjection()
         eq(proj.GetName(), "WGS 84 / UTM zone 27N")
         eq(proj.EPSGCode(), "32627")
@@ -202,7 +203,7 @@
 
         # Check the layer attributes
         layer = layers[0]
-        eq(layer.Title(), "K\xfcste")
+        eq(layer.Title(), internal_from_unicode(u"K\xfcste"))
         self.failUnless(filenames_equal(layer.ShapeStore().FileName(),
                                         os.path.join(self.temp_dir(),
                                                      os.pardir, os.pardir,
@@ -421,7 +422,8 @@
                             ("#000000", 2, "None")),
                          ("single", "1", "",
                             ("#000000", 10, "None")),
-                         ("single", "\xe4\xf6\xfc", "\xdcml\xe4uts",
+                         ("single", internal_from_unicode(u"\xe4\xf6\xfc"),
+                          internal_from_unicode(u"\xdcml\xe4uts"),
                             ("#000000", 1, "None"))]),
                      ("My Layer 2", 4,
                          [("default", (), "",
@@ -690,7 +692,8 @@
 
         label_layer = self.session.Maps()[0].LabelLayer()
         expected_labels = [(-21.5, 64.25, "RUINS", ALIGN_LEFT, ALIGN_CENTER),
-                           (-15.125, 64.75, "H\xfctte", ALIGN_RIGHT, ALIGN_TOP),
+                           (-15.125, 64.75, internal_from_unicode(u"H\xfctte"),
+                            ALIGN_RIGHT, ALIGN_TOP),
                            ]
         for label, values in zip(label_layer.Labels(), expected_labels):
             self.assertEquals((label.x, label.y, label.text, label.halign,

Index: test_load_0_9.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_load_0_9.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- test_load_0_9.py	12 Mar 2004 12:19:15 -0000	1.3
+++ test_load_0_9.py	1 Jul 2005 20:49:04 -0000	1.4
@@ -1,4 +1,4 @@
-# Copyright (c) 2002, 2003, 2004 by Intevation GmbH
+# Copyright (c) 2002, 2003, 2004, 2005 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh at intevation.de>
 #
@@ -26,6 +26,7 @@
 
 import dbflib
 
+from Thuban import internal_from_unicode
 from Thuban.Model.save import save_session
 from Thuban.Model.load import load_session, parse_color, LoadError, \
      LoadCancelled
@@ -169,7 +170,7 @@
         self.session = session
 
         # Check the title
-        eq(session.Title(), "Stra\xdfen & Landmarken")
+        eq(session.Title(), internal_from_unicode(u"Stra\xdfen & Landmarken"))
 
         # the session has one map.
         maps = session.Maps()
@@ -177,7 +178,7 @@
 
         # Check the map's attributes
         map = maps[0]
-        eq(map.Title(), "\xdcbersicht")
+        eq(map.Title(), internal_from_unicode(u"\xdcbersicht"))
 
         # the map has a single layer
         layers = map.Layers()
@@ -185,7 +186,7 @@
 
         # Check the layer attributes
         layer = layers[0]
-        eq(layer.Title(), "K\xfcste")
+        eq(layer.Title(), internal_from_unicode(u"K\xfcste"))
         self.failUnless(filenames_equal(layer.ShapeStore().FileName(),
                                         os.path.join(self.temp_dir(),
                                                      os.pardir, os.pardir,
@@ -305,7 +306,8 @@
                             ("#000000", 2, "None")),
                          ("single", "1", "",
                             ("#000000", 10, "None")),
-                         ("single", "\xe4\xf6\xfc", "\xdcml\xe4uts",
+                         ("single", internal_from_unicode(u"\xe4\xf6\xfc"),
+                          internal_from_unicode(u"\xdcml\xe4uts"),
                             ("#000000", 1, "None"))]),
                      ("My Layer 2", 4,
                          [("default", (), "",

Index: test_load_0_8.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_load_0_8.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- test_load_0_8.py	11 Nov 2003 18:16:53 -0000	1.4
+++ test_load_0_8.py	1 Jul 2005 20:49:04 -0000	1.5
@@ -1,4 +1,4 @@
-# Copyright (c) 2002, 2003 by Intevation GmbH
+# Copyright (c) 2002, 2003, 2005 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh at intevation.de>
 #
@@ -21,6 +21,7 @@
 
 import dbflib
 
+from Thuban import internal_from_unicode
 from Thuban.Model.load import load_session, parse_color, LoadError
 from Thuban.Model.color import Transparent
 from Thuban.Model.classification import ClassGroupProperties, ClassGroupRange,\
@@ -565,21 +566,23 @@
         self.session = session
 
         # Check the title
-        eq(session.Title(), "Frida: Free Vector Geodata Osnabr\xfcck")
+        eq(session.Title(),
+           internal_from_unicode(u"Frida: Free Vector Geodata Osnabr\xfcck"))
 
         # Check the map's title
         maps = session.Maps()
         map = maps[0]
-        eq(map.Title(), "Osnabr\xfcck")
+        eq(map.Title(), internal_from_unicode(u"Osnabr\xfcck"))
 
         # Check the layer's title
         layers = map.Layers()
         layer = layers[0]
-        eq(layer.Title(), "Osnabr\xfcck Layer")
+        eq(layer.Title(), internal_from_unicode(u"Osnabr\xfcck Layer"))
 
         # Check the projection's title
         projection = map.GetProjection()
-        eq(projection.GetName(), "Osnabr\xfcck Projection")
+        eq(projection.GetName(),
+           internal_from_unicode(u"Osnabr\xfcck Projection"))
 
         self.session.Destroy()
         self.session = None

Index: test_load.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_load.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- test_load.py	6 May 2005 14:19:23 -0000	1.46
+++ test_load.py	1 Jul 2005 20:49:04 -0000	1.47
@@ -1,4 +1,4 @@
-# Copyright (c) 2002, 2003, 2004 by Intevation GmbH
+# Copyright (c) 2002, 2003, 2004, 2005 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh at intevation.de>
 #
@@ -40,6 +40,7 @@
 import dbflib
 import shapelib
 
+from Thuban import internal_from_unicode
 from Thuban.Model.save import save_session
 from Thuban.Model.load import load_session, parse_color, LoadError, \
      LoadCancelled
@@ -214,7 +215,7 @@
         self.session = session
 
         # Check the title
-        eq(session.Title(), "Stra\xdfen & Landmarken")
+        eq(session.Title(), internal_from_unicode(u"Stra\xdfen & Landmarken"))
 
         # the session has one map.
         maps = session.Maps()
@@ -222,7 +223,7 @@
 
         # Check the map's attributes
         map = maps[0]
-        eq(map.Title(), "\xdcbersicht")
+        eq(map.Title(), internal_from_unicode(u"\xdcbersicht"))
         proj = map.GetProjection()
         eq(proj.GetName(), "WGS 84 / UTM zone 27N")
         eq(proj.EPSGCode(), "32627")
@@ -237,7 +238,7 @@
 
         # Check the layer attributes
         layer = layers[0]
-        eq(layer.Title(), "K\xfcste")
+        eq(layer.Title(), internal_from_unicode(u"K\xfcste"))
         self.failUnless(filenames_equal(layer.ShapeStore().FileName(),
                                         os.path.join(self.temp_dir(),
                                                      os.pardir, os.pardir,
@@ -510,7 +511,8 @@
                             ("#000000", 2, "None")),
                          ("single", "1", "",
                             ("#000000", 10, "None")),
-                         ("single", "\xe4\xf6\xfc", "\xdcml\xe4uts",
+                         ("single", internal_from_unicode(u"\xe4\xf6\xfc"),
+                          internal_from_unicode(u"\xdcml\xe4uts"),
                             ("#000000", 1, "None"))]),
                      ("My Layer 2", 4,
                          [("default", (), "",
@@ -792,7 +794,8 @@
 
         label_layer = self.session.Maps()[0].LabelLayer()
         expected_labels = [(-21.5, 64.25, "RUINS", ALIGN_LEFT, ALIGN_CENTER),
-                           (-15.125, 64.75, "H\xfctte", ALIGN_RIGHT, ALIGN_TOP),
+                           (-15.125, 64.75, internal_from_unicode(u"H\xfctte"),
+                            ALIGN_RIGHT, ALIGN_TOP),
                            ]
         for label, values in zip(label_layer.Labels(), expected_labels):
             self.assertEquals((label.x, label.y, label.text, label.halign,

Index: support.py
===================================================================
RCS file: /thubanrepository/thuban/test/support.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- support.py	9 May 2005 18:36:02 -0000	1.20
+++ support.py	1 Jul 2005 20:49:04 -0000	1.21
@@ -1,4 +1,4 @@
-# Copyright (c) 2002, 2003, 2004 by Intevation GmbH
+# Copyright (c) 2002, 2003, 2004, 2005 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh at intevation.de>
 #
@@ -64,6 +64,11 @@
         # need to import wxPython
         import Thuban
         Thuban.install_translation_function(lambda s: s)
+
+        # For the time being the default encoding in the test suite is
+        # latin 1.  This is mostly for historical reasons.  Other
+        # encodings can be specified as an argument for runtests.py.
+        Thuban.set_internal_encoding("latin-1")
 
         _initthuban_done = 1
 

Index: runtests.py
===================================================================
RCS file: /thubanrepository/thuban/test/runtests.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- runtests.py	30 Jun 2005 19:24:45 -0000	1.16
+++ runtests.py	1 Jul 2005 20:49:04 -0000	1.17
@@ -74,10 +74,13 @@
 
     verbosity = 1
 
-    opts, args = getopt.getopt(sys.argv[1:], 'v', ['verbose'])
+    opts, args = getopt.getopt(sys.argv[1:], 'v',
+                               ['verbose', "internal-encoding="])
     for optchar, value in opts:
         if optchar in ("-v", "--verbose"):
             verbosity = 2
+        elif optchar == "--internal-encoding":
+            Thuban.set_internal_encoding(value)
         else:
             print>>sys.stderr, "Unknown option", optchar
 





More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)