[Zope3-checkins] CVS: Zope3/src/zope/schema/tests - test_dictfield.py:1.4 test_listfield.py:1.4 test_tuplefield.py:1.4

Richard Jones richard@commonground.com.au
Fri, 11 Jul 2003 22:47:31 -0400


Update of /cvs-repository/Zope3/src/zope/schema/tests
In directory cvs.zope.org:/tmp/cvs-serv26157/src/zope/schema/tests

Modified Files:
	test_dictfield.py test_listfield.py test_tuplefield.py 
Log Message:
Sequence value_types argument is now value_type (ie. a single Field type)
Dict key_types and value_types are also changed to key_type and value_type.
[having multiple value/key types makes no sense and actually makes widgets
extraordinarily difficult to implement (read: approaching impossible :)]


=== Zope3/src/zope/schema/tests/test_dictfield.py 1.3 => 1.4 ===
--- Zope3/src/zope/schema/tests/test_dictfield.py:1.3	Thu May  1 15:35:46 2003
+++ Zope3/src/zope/schema/tests/test_dictfield.py	Fri Jul 11 22:47:26 2003
@@ -79,29 +79,33 @@
         self.assertRaisesErrorNames(errornames.TooLong,
                                     field.validate, {1: 'a', 2: 'b', 3: 'c'})
 
-    def testValidateValueTypes(self):
+    def testValidateValueType(self):
         field = Dict(title=u'Dict field',
                      description=u'', readonly=False, required=False,
-                     value_types=(Int(), Float()))
+                     value_type=Int())
         field.validate(None)
-        field.validate({'a': 5.3})
-        field.validate({'a': 2, 'b': 2.3})
+        field.validate({'a': 5})
+        field.validate({'a': 2, 'b': 3})
 
         self.assertRaisesErrorNames(errornames.WrongContainedType,
                                     field.validate, {1: ''} )
         self.assertRaisesErrorNames(errornames.WrongContainedType,
+                                    field.validate, {1: 3.14159} )
+        self.assertRaisesErrorNames(errornames.WrongContainedType,
                                     field.validate, {'a': ()} )
 
     def testValidateKeyTypes(self):
         field = Dict(title=u'Dict field',
                      description=u'', readonly=False, required=False,
-                     key_types=(Int(), Float()))
+                     key_type=Int())
         field.validate(None)
-        field.validate({5.3: 'a'})
-        field.validate({2: 'a', 2.3: 'b'})
+        field.validate({5: 'a'})
+        field.validate({2: 'a', 2: 'b'})
 
         self.assertRaisesErrorNames(errornames.WrongContainedType,
                                     field.validate, {'': 1} )
+        self.assertRaisesErrorNames(errornames.WrongContainedType,
+                                    field.validate, {3.14159: 1} )
         self.assertRaisesErrorNames(errornames.WrongContainedType,
                                     field.validate, {(): 'a'} )
 


=== Zope3/src/zope/schema/tests/test_listfield.py 1.3 => 1.4 ===
--- Zope3/src/zope/schema/tests/test_listfield.py:1.3	Thu May  1 15:35:46 2003
+++ Zope3/src/zope/schema/tests/test_listfield.py	Fri Jul 11 22:47:26 2003
@@ -82,15 +82,15 @@
     def testValidateValueTypes(self):
         field = List(title=u'List field', description=u'',
                      readonly=False, required=False,
-                     value_types=(Int(), Float()))
+                     value_type=Int())
         field.validate(None)
-        field.validate([5.3,])
-        field.validate([2, 2.3])
+        field.validate([5,])
+        field.validate([2, 3])
 
         self.assertRaisesErrorNames(errornames.WrongContainedType,
                                     field.validate, ['',] )
         self.assertRaisesErrorNames(errornames.WrongContainedType,
-                                    field.validate, [2, ''] )
+                                    field.validate, [3.14159,] )
 
 def test_suite():
     return makeSuite(ListTest)


=== Zope3/src/zope/schema/tests/test_tuplefield.py 1.3 => 1.4 ===
--- Zope3/src/zope/schema/tests/test_tuplefield.py:1.3	Fri Jan 24 22:53:40 2003
+++ Zope3/src/zope/schema/tests/test_tuplefield.py	Fri Jul 11 22:47:26 2003
@@ -122,15 +122,15 @@
     def testValidateValueTypes(self):
         field = Tuple(title=u'Tuple field', description=u'',
                       readonly=False, required=False,
-                      value_types=(Int(), Float()))
+                      value_type=Int())
         field.validate(None)
-        field.validate((5.3,))
-        field.validate((2, 2.3))
+        field.validate((5,))
+        field.validate((2, 3))
 
         self.assertRaisesErrorNames(errornames.WrongContainedType,
                                     field.validate, ('',) )
         self.assertRaisesErrorNames(errornames.WrongContainedType,
-                                    field.validate, (2, '') )
+                                    field.validate, (3.14159,) )
 
 def test_suite():
     suite = TestSuite()