[Zope3-checkins] CVS: StandaloneZConfig/ZConfig/tests - test_datatypes.py:1.12

Fred L. Drake, Jr. fred at zope.com
Fri Mar 19 11:08:11 EST 2004


Update of /cvs-repository/StandaloneZConfig/ZConfig/tests
In directory cvs.zope.org:/tmp/cvs-serv26015/tests

Modified Files:
	test_datatypes.py 
Log Message:
fix support for Python compiled without Unicode support


=== StandaloneZConfig/ZConfig/tests/test_datatypes.py 1.11 => 1.12 ===
--- StandaloneZConfig/ZConfig/tests/test_datatypes.py:1.11	Tue Mar 16 16:28:40 2004
+++ StandaloneZConfig/ZConfig/tests/test_datatypes.py	Fri Mar 19 11:08:03 2004
@@ -31,6 +31,13 @@
 
 StringType = type("")
 
+try:
+    unicode
+except NameError:
+    have_unicode = 0
+else:
+    have_unicode = 1
+
 
 class DatatypeTestCase(unittest.TestCase):
     types = ZConfig.datatypes.Registry()
@@ -91,6 +98,11 @@
         raises(ValueError, convert, "-inf")
         raises(ValueError, convert, "nan")
 
+        if have_unicode:
+            raises(ValueError, convert, unicode("inf"))
+            raises(ValueError, convert, unicode("-inf"))
+            raises(ValueError, convert, unicode("nan"))
+
     def test_datatype_identifier(self):
         convert = self.types.get("identifier")
         raises = self.assertRaises
@@ -112,6 +124,11 @@
         v = convert(value)
         self.assertEqual(v, value)
         self.assert_(isinstance(v, StringType))
+        if have_unicode:
+            unicode_value = unicode(value)
+            v = convert(unicode_value)
+            self.assertEqual(v, value)
+            self.assert_(isinstance(v, StringType))
 
     def check_never_namelike(self, convert):
         raises = self.assertRaises




More information about the Zope3-Checkins mailing list