[Zope3-checkins] CVS: Zope3/lib/python/Zope/Schema/tests - testBoolField.py:1.2 testDictField.py:1.2 testField.py:1.2 testFieldProperty.py:1.2 testFloatField.py:1.2 testIntField.py:1.2 testListField.py:1.2 testSchema.py:1.3 testStrField.py:1.3 testTupleField.py:1.2

Jim Fulton jim@zope.com
Wed, 11 Sep 2002 18:06:42 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Schema/tests
In directory cvs.zope.org:/tmp/cvs-serv7363/tests

Modified Files:
	testBoolField.py testDictField.py testField.py 
	testFieldProperty.py testFloatField.py testIntField.py 
	testListField.py testSchema.py testStrField.py 
	testTupleField.py 
Log Message:
Major refactoring of schemas:

  - Ripped out the validation framework. Fields now coordinate
    validation through inheritence with the help of super. I'm a big
    fan of super.

  - Field constructors no longer accept and set arbitrary field
    parameters. Fields only accepr keyword settings for settable
    attributes. 

  - Almost all field attributes are implemented with property-like
    objects that validate field attribute values. 

  - Field titles and descriptions are now unicode.

  - Field __name__ and __doc__ attributes can now ne provided with
    constructor keyword arguments.  The __name__ attribute is normally
    provided automatically by the interface initialization machinery.
    It might be useful to provide a __name__ attribute explicitly when
    a field is used outside of an interface.  If no __doc__ value is
    provided in the constructor, one will be computed from the title
    and description.

  - Fields can now be given an atribtrary constraint, which is just a
    callable object that returns a true value if the constraint is
    satisfied and false otherwise. It could also raise a
    ValidationError to provide an error message.

  - Fields keep track of the order in which they are defined. This is
    helpful for automatic form generation to get the form fields in
    the same order as the schema fields.

  - The sequence and dictionary fields (is anyone using these?) now
    restrict contents using fields, rather than types.

  - Float fields no longer accept ints.

  - Int fields now accept longs.

  - Handling of field attributes like default, min, max, and
    allowed_values are now defined recursively and validated with
    specialized properties. This allowed the definition of field
    interfaces and bootstrapping to be simplified.

  - Got rid of Float.decimals. YAGNI.

  - Boolean fields no longer have an allowable_values attribute. ;)

  - A number of new abstract field interfaces and implementations were
    added.




=== Zope3/lib/python/Zope/Schema/tests/testBoolField.py 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/Schema/tests/testBoolField.py:1.1	Thu Sep  5 14:55:04 2002
+++ Zope3/lib/python/Zope/Schema/tests/testBoolField.py	Wed Sep 11 18:06:41 2002
@@ -16,13 +16,13 @@
 """
 from unittest import TestSuite, main, makeSuite
 from Zope.Schema import Bool, ErrorNames
-from testField import FieldTest
+from testField import FieldTestBase
 
-class BoolTest(FieldTest):
+class BoolTest(FieldTestBase):
     """Test the Bool Field."""
 
     def testValidate(self):
-        field = Bool(id="field", title='Bool field', description='',
+        field = Bool(title=u'Bool field', description=u'',
                         readonly=0, required=0)        
         field.validate(None)
         field.validate(1)
@@ -31,22 +31,13 @@
         field.validate(-10)
 
     def testValidateRequired(self):
-        field = Bool(id="field", title='Bool field', description='',
+        field = Bool(title=u'Bool field', description=u'',
                         readonly=0, required=1)
         field.validate(1)
         field.validate(0)
 
         self.assertRaisesErrorNames(ErrorNames.RequiredMissing,
                                     field.validate, None)
-
-    def testAllowedValues(self):
-        field = Bool(id="field", title='Bool field', description='',
-                        readonly=0, required=0, allowed_values=(0,))
-        field.validate(None)
-        field.validate(0)
-
-        self.assertRaisesErrorNames(ErrorNames.InvalidValue,
-                                    field.validate, 1)
 
 
 def test_suite():


=== Zope3/lib/python/Zope/Schema/tests/testDictField.py 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/Schema/tests/testDictField.py:1.1	Thu Sep  5 14:55:04 2002
+++ Zope3/lib/python/Zope/Schema/tests/testDictField.py	Wed Sep 11 18:06:41 2002
@@ -16,22 +16,22 @@
 """
 from unittest import TestSuite, main, makeSuite
 from Zope.Schema import Dict, Int, Float, ErrorNames
-from testField import FieldTest
+from testField import FieldTestBase
 
-class DictTest(FieldTest):
+class DictTest(FieldTestBase):
     """Test the Dict Field."""
 
     def testValidate(self):
-        field = Dict(id="field", title='Dict field',
-                           description='', readonly=0, required=0)
+        field = Dict(title=u'Dict field',
+                     description=u'', readonly=0, required=0)
         field.validate(None)
         field.validate({})
         field.validate({1: 'foo'})
         field.validate({'a': 1})
             
     def testValidateRequired(self):
-        field = Dict(id="field", title='Dict field',
-                           description='', readonly=0, required=1)
+        field = Dict(title=u'Dict field',
+                     description=u'', readonly=0, required=1)
         field.validate({})
         field.validate({1: 'foo'})
         field.validate({'a': 1})
@@ -40,46 +40,46 @@
                                     field.validate, None)
 
     def testValidateMinValues(self):
-        field = Dict(id="field", title='Dict field',
-                           description='', readonly=0, required=0,
-                           min_values=1)    
+        field = Dict(title=u'Dict field',
+                     description=u'', readonly=0, required=0,
+                     min_length=1)    
         field.validate(None)
         field.validate({1: 'a'})
         field.validate({1: 'a', 2: 'b'})
     
-        self.assertRaisesErrorNames(ErrorNames.NotEnoughElements,
+        self.assertRaisesErrorNames(ErrorNames.TooShort,
                                     field.validate, {})
 
     def testValidateMaxValues(self):
-        field = Dict(id="field", title='Dict field',
-                           description='', readonly=0, required=0,
-                           max_values=1)
+        field = Dict(title=u'Dict field',
+                     description=u'', readonly=0, required=0,
+                     max_length=1)
         field.validate(None)
         field.validate({})
         field.validate({1: 'a'})
     
-        self.assertRaisesErrorNames(ErrorNames.TooManyElements,
+        self.assertRaisesErrorNames(ErrorNames.TooLong,
                                     field.validate, {1: 'a', 2: 'b'})
-        self.assertRaisesErrorNames(ErrorNames.TooManyElements,
+        self.assertRaisesErrorNames(ErrorNames.TooLong,
                                     field.validate, {1: 'a', 2: 'b', 3: 'c'})
 
     def testValidateMinValuesAndMaxValues(self):
-        field = Dict(id="field", title='Dict field',
-                           description='', readonly=0, required=0,
-                           min_values=1, max_values=2)
+        field = Dict(title=u'Dict field',
+                     description=u'', readonly=0, required=0,
+                     min_length=1, max_length=2)
         field.validate(None)
         field.validate({1: 'a'})
         field.validate({1: 'a', 2: 'b'})
     
-        self.assertRaisesErrorNames(ErrorNames.NotEnoughElements,
+        self.assertRaisesErrorNames(ErrorNames.TooShort,
                                     field.validate, {})
-        self.assertRaisesErrorNames(ErrorNames.TooManyElements,
+        self.assertRaisesErrorNames(ErrorNames.TooLong,
                                     field.validate, {1: 'a', 2: 'b', 3: 'c'})
 
     def testValidateValueTypes(self):
-        field = Dict(id="field", title='Dict field',
-                           description='', readonly=0, required=0,
-                           value_types=(Int, Float))
+        field = Dict(title=u'Dict field',
+                     description=u'', readonly=0, required=0,
+                     value_types=(Int(), Float()))
         field.validate(None)
         field.validate({'a': 5.3})
         field.validate({'a': 2, 'b': 2.3})
@@ -90,13 +90,13 @@
                                     field.validate, {'a': ()} )
 
     def testValidateKeyTypes(self):
-        field = Dict(id="field", title='Dict field',
-                           description='', readonly=0, required=0,
-                           key_types=(Int, Float))
+        field = Dict(title=u'Dict field',
+                     description=u'', readonly=0, required=0,
+                     key_types=(Int(), Float()))
         field.validate(None)
         field.validate({5.3: 'a'})
         field.validate({2: 'a', 2.3: 'b'})
-    
+
         self.assertRaisesErrorNames(ErrorNames.WrongContainedType,
                                     field.validate, {'': 1} )
         self.assertRaisesErrorNames(ErrorNames.WrongContainedType,


=== Zope3/lib/python/Zope/Schema/tests/testField.py 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/Schema/tests/testField.py:1.1	Thu Sep  5 14:55:04 2002
+++ Zope3/lib/python/Zope/Schema/tests/testField.py	Wed Sep 11 18:06:41 2002
@@ -15,23 +15,25 @@
 $Id$
 """
 from unittest import TestCase, TestSuite, main, makeSuite
-from Zope.Schema import Field, IField, ErrorNames
+from Zope.Schema import Field, Text, IField, ErrorNames
 from Zope.Schema.Exceptions import StopValidation, ValidationError
 
-
-class FieldTest(TestCase):
-    """Test generic Field."""
+class FieldTestBase(TestCase):
 
     def assertRaisesErrorNames(self, error_name, f, *args, **kw):
         try:
             f(*args, **kw)
         except ValidationError, e:
-            self.assertEquals(error_name, e.error_name)
+            self.assertEquals(error_name, e[0])
             return
         self.fail('Expected ValidationError')
 
+
+class FieldTest(FieldTestBase):
+    """Test generic Field."""
+
     def testValidate(self):
-        field = Field(id="field", title='Not required field', description='',
+        field = Field(title=u'Not required field', description=u'',
                       readonly=0, required=0)
         field.validate(None)
         field.validate('foo')
@@ -40,7 +42,7 @@
         field.validate('')
     
     def testValidateRequired(self):
-        field = Field(id="field", title='Required field', description='',
+        field = Field(title=u'Required field', description=u'',
                       readonly=0, required=1)
         field.validate('foo')
         field.validate(1)
@@ -50,6 +52,41 @@
         self.assertRaisesErrorNames(ErrorNames.RequiredMissing,
                                     field.validate, None)
 
+    def testSillyDefault(self):
+        
+        self.assertRaises(ValidationError, Text, default="")
+
+    def test__doc__(self):
+        field = Text(title=u"test fiield",
+                     description=(
+                         u"To make sure that\n"
+                         u"doc strings are working correctly\n"
+                         )
+                     )
+        self.assertEqual(
+            field.__doc__,
+            u"test fiield\n\n"
+            u"To make sure that\n"
+            u"doc strings are working correctly\n"
+            )
+
+    def testOrdering(self):
+
+        from Interface import Interface
+
+        class S1(Interface):
+            a = Text()
+            b = Text()
+
+        self.failUnless(S1['a'].order < S1['b'].order)
+
+        class S2(Interface):
+            b = Text()
+            a = Text()
+
+        self.failUnless(S2['a'].order > S2['b'].order)
+                           
+        
 
 def test_suite():
     return makeSuite(FieldTest)


=== Zope3/lib/python/Zope/Schema/tests/testFieldProperty.py 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/Schema/tests/testFieldProperty.py:1.1	Sat Sep  7 12:18:51 2002
+++ Zope3/lib/python/Zope/Schema/tests/testFieldProperty.py	Wed Sep 11 18:06:41 2002
@@ -24,7 +24,7 @@
 
 class I(Interface):
 
-    title = Text(description="Short summary", default=u'say something')
+    title = Text(description=u"Short summary", default=u'say something')
     weight = Float(min=0.0)
     code = Bytes(min_length=6, max_length=6, default='xxxxxx')
 
@@ -43,13 +43,14 @@
         self.assertEqual(c.code, 'xxxxxx')
         self.assertRaises(ValidationError, setattr, c, 'title', 'foo')
         self.assertRaises(ValidationError, setattr, c, 'weight', 'foo')
-        self.assertRaises(ValidationError, setattr, c, 'weight', -1)
+        self.assertRaises(ValidationError, setattr, c, 'weight', -1.0)
+        self.assertRaises(ValidationError, setattr, c, 'weight', 2)
         self.assertRaises(ValidationError, setattr, c, 'code', -1)
         self.assertRaises(ValidationError, setattr, c, 'code', 'xxxx')
         self.assertRaises(ValidationError, setattr, c, 'code', u'xxxxxx')
 
         c.title = u'c is good'
-        c.weight = 10
+        c.weight = 10.0
         c.code = 'abcdef'
 
         self.assertEqual(c.title, u'c is good')


=== Zope3/lib/python/Zope/Schema/tests/testFloatField.py 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/Schema/tests/testFloatField.py:1.1	Thu Sep  5 14:55:04 2002
+++ Zope3/lib/python/Zope/Schema/tests/testFloatField.py	Wed Sep 11 18:06:41 2002
@@ -16,13 +16,13 @@
 """
 from unittest import TestSuite, main, makeSuite
 from Zope.Schema import Float, ErrorNames
-from testField import FieldTest
+from testField import FieldTestBase
 
-class FloatTest(FieldTest):
+class FloatTest(FieldTestBase):
     """Test the Float Field."""
 
     def testValidate(self):
-        field = Float(id="field", title='Float field', description='',
+        field = Float(title=u'Float field', description=u'',
                         readonly=0, required=0)
         field.validate(None)
         field.validate(10.0)
@@ -30,7 +30,7 @@
         field.validate(1000.0003)
     
     def testValidateRequired(self):
-        field = Float(id="field", title='Float field', description='',
+        field = Float(title=u'Float field', description=u'',
                         readonly=0, required=1)
         field.validate(10.0)
         field.validate(0.93)
@@ -39,7 +39,7 @@
         self.assertRaisesErrorNames(ErrorNames.RequiredMissing,
                                     field.validate, None)        
     def testAllowedValues(self):
-        field = Float(id="field", title='Integer field', description='',
+        field = Float(title=u'Integer field', description=u'',
                         readonly=0, required=0, allowed_values=(0.1, 2.6))
         field.validate(None)
         field.validate(2.6)
@@ -48,17 +48,17 @@
                                     field.validate, -5.4)
 
     def testValidateMin(self):
-        field = Float(id="field", title='Float field', description='',
+        field = Float(title=u'Float field', description=u'',
                         readonly=0, required=0, min=10.5)
         field.validate(None)
         field.validate(10.6)
         field.validate(20.2)
 
-        self.assertRaisesErrorNames(ErrorNames.TooSmall, field.validate, -9)
+        self.assertRaisesErrorNames(ErrorNames.TooSmall, field.validate, -9.0)
         self.assertRaisesErrorNames(ErrorNames.TooSmall, field.validate, 10.4)
 
     def testValidateMax(self):
-        field = Float(id="field", title='Float field', description='',
+        field = Float(title=u'Float field', description=u'',
                         readonly=0, required=0, max=10.5)
         field.validate(None)
         field.validate(5.3)
@@ -68,29 +68,17 @@
         self.assertRaisesErrorNames(ErrorNames.TooBig, field.validate, 20.7)
 
     def testValidateMinAndMax(self):
-        field = Float(id="field", title='Float field', description='',
+        field = Float(title=u'Float field', description=u'',
                         readonly=0, required=0, min=-0.6, max=10.1)
         field.validate(None)
-        field.validate(0)
+        field.validate(0.0)
         field.validate(-0.03)
         field.validate(10.0001)
 
-        self.assertRaisesErrorNames(ErrorNames.TooSmall, field.validate, -10)
+        self.assertRaisesErrorNames(ErrorNames.TooSmall, field.validate, -10.0)
         self.assertRaisesErrorNames(ErrorNames.TooSmall, field.validate, -1.6)
         self.assertRaisesErrorNames(ErrorNames.TooBig, field.validate, 11.45)
         self.assertRaisesErrorNames(ErrorNames.TooBig, field.validate, 20.02)
-
-    def testValidateDecimals(self):
-        field = Float(id="field", title='Float field', description='',
-                        readonly=0, required=0, decimals=2)
-        field.validate(None)
-        field.validate(5.3)
-        field.validate(-9.11)
-
-        self.assertRaisesErrorNames(ErrorNames.TooManyDecimals,
-                                    field.validate, 10.511)
-        self.assertRaisesErrorNames(ErrorNames.TooManyDecimals,
-                                    field.validate, 20.7122)
 
 
 def test_suite():


=== Zope3/lib/python/Zope/Schema/tests/testIntField.py 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/Schema/tests/testIntField.py:1.1	Thu Sep  5 14:55:04 2002
+++ Zope3/lib/python/Zope/Schema/tests/testIntField.py	Wed Sep 11 18:06:41 2002
@@ -16,13 +16,13 @@
 """
 from unittest import TestSuite, main, makeSuite
 from Zope.Schema import Int, ErrorNames
-from testField import FieldTest
+from testField import FieldTestBase
 
-class IntTest(FieldTest):
+class IntTest(FieldTestBase):
     """Test the Int Field."""
 
     def testValidate(self):
-        field = Int(id="field", title='Int field', description='',
+        field = Int(title=u'Int field', description=u'',
                         readonly=0, required=0)
         field.validate(None)
         field.validate(10)
@@ -30,7 +30,7 @@
         field.validate(-1)
         
     def testValidateRequired(self):
-        field = Int(id="field", title='Int field', description='',
+        field = Int(title=u'Int field', description=u'',
                     readonly=0, required=1)
         field.validate(10)
         field.validate(0)
@@ -40,7 +40,7 @@
                                     field.validate, None)
 
     def testAllowedValues(self):
-        field = Int(id="field", title='Int field', description='',
+        field = Int(title=u'Int field', description=u'',
                         readonly=0, required=0, allowed_values=(-1, 2))
         field.validate(None)
         field.validate(2)
@@ -49,7 +49,7 @@
                                     field.validate, 4)
 
     def testValidateMin(self):
-        field = Int(id="field", title='Int field', description='',
+        field = Int(title=u'Int field', description=u'',
                         readonly=0, required=0, min=10)
         field.validate(None)
         field.validate(10)
@@ -59,7 +59,7 @@
         self.assertRaisesErrorNames(ErrorNames.TooSmall, field.validate, -10)
 
     def testValidateMax(self):
-        field = Int(id="field", title='Int field', description='',
+        field = Int(title=u'Int field', description=u'',
                         readonly=0, required=0, max=10)
         field.validate(None)
         field.validate(5)
@@ -69,7 +69,7 @@
         self.assertRaisesErrorNames(ErrorNames.TooBig, field.validate, 20)
 
     def testValidateMinAndMax(self):
-        field = Int(id="field", title='Int field', description='',
+        field = Int(title=u'Int field', description=u'',
                         readonly=0, required=0, min=0, max=10)
         field.validate(None)
         field.validate(0)


=== Zope3/lib/python/Zope/Schema/tests/testListField.py 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/Schema/tests/testListField.py:1.1	Thu Sep  5 14:55:04 2002
+++ Zope3/lib/python/Zope/Schema/tests/testListField.py	Wed Sep 11 18:06:41 2002
@@ -16,13 +16,13 @@
 """
 from unittest import TestSuite, main, makeSuite
 from Zope.Schema import List, Int, Float, ErrorNames
-from testField import FieldTest
+from testField import FieldTestBase
 
-class ListTest(FieldTest):
+class ListTest(FieldTestBase):
     """Test the List Field."""
 
     def testValidate(self):
-        field = List(id="field", title='List field', description='',
+        field = List(title=u'List field', description=u'',
                         readonly=0, required=0)
         field.validate(None)
         field.validate([])
@@ -30,7 +30,7 @@
         field.validate([3,])
         
     def testValidateRequired(self):
-        field = List(id="field", title='List field', description='',
+        field = List(title=u'List field', description=u'',
                         readonly=0, required=1)
         field.validate([])
         field.validate([1, 2])
@@ -40,44 +40,44 @@
                                     field.validate, None)
 
     def testValidateMinValues(self):
-        field = List(id="field", title='List field', description='',
-                        readonly=0, required=0, min_values=2)
+        field = List(title=u'List field', description=u'',
+                        readonly=0, required=0, min_length=2)
         field.validate(None)
         field.validate([1, 2])
         field.validate([1, 2, 3])
     
-        self.assertRaisesErrorNames(ErrorNames.NotEnoughElements,
+        self.assertRaisesErrorNames(ErrorNames.TooShort,
                                     field.validate, [])
-        self.assertRaisesErrorNames(ErrorNames.NotEnoughElements,
+        self.assertRaisesErrorNames(ErrorNames.TooShort,
                                     field.validate, [1,])
 
     def testValidateMaxValues(self):
-        field = List(id="field", title='List field', description='',
-                        readonly=0, required=0, max_values=2)
+        field = List(title=u'List field', description=u'',
+                        readonly=0, required=0, max_length=2)
         field.validate(None)
         field.validate([])
         field.validate([1, 2])
     
-        self.assertRaisesErrorNames(ErrorNames.TooManyElements,
+        self.assertRaisesErrorNames(ErrorNames.TooLong,
                                     field.validate, [1, 2, 3, 4])
-        self.assertRaisesErrorNames(ErrorNames.TooManyElements,
+        self.assertRaisesErrorNames(ErrorNames.TooLong,
                                     field.validate, [1, 2, 3])
 
     def testValidateMinValuesAndMaxValues(self):
-        field = List(id="field", title='List field', description='',
-                        readonly=0, required=0, min_values=1, max_values=2)
+        field = List(title=u'List field', description=u'',
+                        readonly=0, required=0, min_length=1, max_length=2)
         field.validate(None)
         field.validate([1, ])
         field.validate([1, 2])
 
-        self.assertRaisesErrorNames(ErrorNames.NotEnoughElements,
+        self.assertRaisesErrorNames(ErrorNames.TooShort,
                                     field.validate, [])
-        self.assertRaisesErrorNames(ErrorNames.TooManyElements,
+        self.assertRaisesErrorNames(ErrorNames.TooLong,
                                     field.validate, [1, 2, 3])
 
     def testValidateValueTypes(self):
-        field = List(id="field", title='List field', description='',
-                        readonly=0, required=0, value_types=(Int, Float))
+        field = List(title=u'List field', description=u'',
+                        readonly=0, required=0, value_types=(Int(), Float()))
         field.validate(None)
         field.validate([5.3,])
         field.validate([2, 2.3])


=== Zope3/lib/python/Zope/Schema/tests/testSchema.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/Schema/tests/testSchema.py:1.2	Sat Sep  7 12:18:51 2002
+++ Zope3/lib/python/Zope/Schema/tests/testSchema.py	Wed Sep 11 18:06:41 2002
@@ -23,20 +23,20 @@
 
 class ISchemaTest(Interface):
     title = Bytes(
-        title="Title",
-        description="Title",
+        title=u"Title",
+        description=u"Title",
         default="",
         required=1)
     
     description = Bytes(
-        title="Description",
-        description="Description",
+        title=u"Description",
+        description=u"Description",
         default="",
         required=1)
 
     spam = Bytes(
-        title="Spam",
-        description="Spam",
+        title=u"Spam",
+        description=u"Spam",
         default="",
         required=1)
 


=== Zope3/lib/python/Zope/Schema/tests/testStrField.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/Schema/tests/testStrField.py:1.2	Sat Sep  7 12:18:51 2002
+++ Zope3/lib/python/Zope/Schema/tests/testStrField.py	Wed Sep 11 18:06:41 2002
@@ -17,31 +17,37 @@
 from unittest import TestSuite, main, makeSuite
 from Zope.Schema import Bytes, Text, ErrorNames
 from Zope.Schema.Exceptions import ValidationError 
-from testField import FieldTest
+from testField import FieldTestBase
 
-class StrTest(FieldTest):
+class StrTest(FieldTestBase):
     """Test the Str Field."""
 
     def testValidate(self):
-        field = self._Str(id='field', title='Str field', description='',
+        field = self._Str(title=u'Str field', description=u'',
                        readonly=0, required=0)
         field.validate(None)
         field.validate(self._convert('foo'))
         field.validate(self._convert(''))
     
     def testValidateRequired(self):
-        field = self._Str(id='field', title='Str field', description='',
-                       readonly=0, required=1)
+
+        # Note that if we want to require non-empty strings,
+        # we need to set the min-length to 1.
+        
+        field = self._Str(title=u'Str field', description=u'',
+                          readonly=0, required=1, min_length=1)
         field.validate(self._convert('foo'))
 
         self.assertRaisesErrorNames(ErrorNames.RequiredMissing,
                                     field.validate, None)
-        self.assertRaisesErrorNames(ErrorNames.RequiredEmptyStr,
+        self.assertRaisesErrorNames(ErrorNames.TooShort,
                                     field.validate, self._convert(''))
 
     def testAllowedValues(self):
-        field = self._Str(id="field", title='Str field', description='',
-                        readonly=0, required=0, allowed_values=('foo', 'bar'))
+        field = self._Str(title=u'Str field', description=u'',
+                          readonly=0, required=0,
+                          allowed_values=(self._convert('foo'),
+                                          self._convert('bar')))
         field.validate(None)
         field.validate(self._convert('foo'))
 
@@ -49,7 +55,7 @@
                                     field.validate, self._convert('blah'))
 
     def testValidateMinLength(self):
-        field = self._Str(id='field', title='Str field', description='',
+        field = self._Str(title=u'Str field', description=u'',
                        readonly=0, required=0, min_length=3)
         field.validate(None)
         field.validate(self._convert('333'))
@@ -63,7 +69,7 @@
                                     field.validate, self._convert('1'))
 
     def testValidateMaxLength(self):
-        field = self._Str(id='field', title='Str field', description='',
+        field = self._Str(title=u'Str field', description=u'',
                        readonly=0, required=0, max_length=5)
         field.validate(None)
         field.validate(self._convert(''))
@@ -76,7 +82,7 @@
                                     self._convert('999999999'))
 
     def testValidateMinLengthAndMaxLength(self):
-        field = self._Str(id='field', title='Str field', description='',
+        field = self._Str(title=u'Str field', description=u'',
                        readonly=0, required=0, min_length=3, max_length=5)
 
         field.validate(None)


=== Zope3/lib/python/Zope/Schema/tests/testTupleField.py 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/Schema/tests/testTupleField.py:1.1	Thu Sep  5 14:55:04 2002
+++ Zope3/lib/python/Zope/Schema/tests/testTupleField.py	Wed Sep 11 18:06:41 2002
@@ -16,21 +16,21 @@
 """
 from unittest import TestSuite, main, makeSuite
 from Zope.Schema import Tuple, Int, Float, ErrorNames
-from testField import FieldTest
+from testField import FieldTestBase
 
-class TupleTest(FieldTest):
+class TupleTest(FieldTestBase):
     """Test the Tuple Field."""
 
     def testValidate(self):
-        field = Tuple(id="field", title='Tuple field', description='',
-                        readonly=0, required=0)
+        field = Tuple(title=u'Tuple field', description=u'',
+                      readonly=0, required=0)
         field.validate(None)
         field.validate(())
         field.validate((1, 2))
         field.validate((3,))
         
     def testValidateRequired(self):
-        field = Tuple(id="field", title='Tuple field', description='',
+        field = Tuple(title=u'Tuple field', description=u'',
                         readonly=0, required=1)
         field.validate(())
         field.validate((1, 2))
@@ -40,44 +40,44 @@
                                     field.validate, None)
 
     def testValidateMinValues(self):
-        field = Tuple(id="field", title='Tuple field', description='',
-                        readonly=0, required=0, min_values=2)
+        field = Tuple(title=u'Tuple field', description=u'',
+                        readonly=0, required=0, min_length=2)
         field.validate(None)
         field.validate((1, 2))
         field.validate((1, 2, 3))
 
-        self.assertRaisesErrorNames(ErrorNames.NotEnoughElements,
+        self.assertRaisesErrorNames(ErrorNames.TooShort,
                                     field.validate, ())
-        self.assertRaisesErrorNames(ErrorNames.NotEnoughElements,
+        self.assertRaisesErrorNames(ErrorNames.TooShort,
                                     field.validate, (1,))
 
     def testValidateMaxValues(self):
-        field = Tuple(id="field", title='Tuple field', description='',
-                        readonly=0, required=0, max_values=2)
+        field = Tuple(title=u'Tuple field', description=u'',
+                        readonly=0, required=0, max_length=2)
         field.validate(None)
         field.validate(())
         field.validate((1, 2))
 
-        self.assertRaisesErrorNames(ErrorNames.TooManyElements,
+        self.assertRaisesErrorNames(ErrorNames.TooLong,
                                     field.validate, (1, 2, 3, 4))
-        self.assertRaisesErrorNames(ErrorNames.TooManyElements,
+        self.assertRaisesErrorNames(ErrorNames.TooLong,
                                     field.validate, (1, 2, 3))
 
     def testValidateMinValuesAndMaxValues(self):
-        field = Tuple(id="field", title='Tuple field', description='',
-                        readonly=0, required=0, min_values=1, max_values=2)
+        field = Tuple(title=u'Tuple field', description=u'',
+                        readonly=0, required=0, min_length=1, max_length=2)
         field.validate(None)
         field.validate((1, ))
         field.validate((1, 2))
 
-        self.assertRaisesErrorNames(ErrorNames.NotEnoughElements,
+        self.assertRaisesErrorNames(ErrorNames.TooShort,
                                     field.validate, ())
-        self.assertRaisesErrorNames(ErrorNames.TooManyElements,
+        self.assertRaisesErrorNames(ErrorNames.TooLong,
                                     field.validate, (1, 2, 3))
 
     def testValidateValueTypes(self):
-        field = Tuple(id="field", title='Tuple field', description='',
-                        readonly=0, required=0, value_types=(Int, Float))
+        field = Tuple(title=u'Tuple field', description=u'',
+                      readonly=0, required=0, value_types=(Int(), Float()))
         field.validate(None)
         field.validate((5.3,))
         field.validate((2, 2.3))