[Zope3-checkins] CVS: Zope3/src/zope/schema/tests - test_boolfield.py:1.4 test_containerfield.py:1.3 test_date.py:1.3 test_datetime.py:1.4 test_dictfield.py:1.6 test_field.py:1.6 test_floatfield.py:1.4 test_interfacefield.py:1.3 test_intfield.py:1.5 test_iterablefield.py:1.3 test_listfield.py:1.6 test_objectfield.py:1.4 test_strfield.py:1.4 test_tuplefield.py:1.7

Stephan Richter srichter at cosmos.phy.tufts.edu
Sun Apr 11 06:35:19 EDT 2004


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

Modified Files:
	test_boolfield.py test_containerfield.py test_date.py 
	test_datetime.py test_dictfield.py test_field.py 
	test_floatfield.py test_interfacefield.py test_intfield.py 
	test_iterablefield.py test_listfield.py test_objectfield.py 
	test_strfield.py test_tuplefield.py 
Log Message:


Updated tests to use error classes instead of error names.




=== Zope3/src/zope/schema/tests/test_boolfield.py 1.3 => 1.4 ===
--- Zope3/src/zope/schema/tests/test_boolfield.py:1.3	Thu May  1 15:35:46 2003
+++ Zope3/src/zope/schema/tests/test_boolfield.py	Sun Apr 11 06:35:17 2004
@@ -16,7 +16,7 @@
 """
 from unittest import main, makeSuite
 from zope.schema import Bool
-from zope.schema.errornames import RequiredMissing
+from zope.schema.interfaces import RequiredMissing
 from zope.schema.tests.test_field import FieldTestBase
 
 class BoolTest(FieldTestBase):
@@ -37,7 +37,7 @@
         field.validate(True)
         field.validate(False)
 
-        self.assertRaisesErrorNames(RequiredMissing, field.validate, None)
+        self.assertRaises(RequiredMissing, field.validate, None)
 
 
 def test_suite():


=== Zope3/src/zope/schema/tests/test_containerfield.py 1.2 => 1.3 ===
--- Zope3/src/zope/schema/tests/test_containerfield.py:1.2	Thu May  1 15:35:46 2003
+++ Zope3/src/zope/schema/tests/test_containerfield.py	Sun Apr 11 06:35:17 2004
@@ -17,7 +17,7 @@
 from UserDict import UserDict
 from unittest import main, makeSuite
 from zope.schema import Container
-from zope.schema.errornames import RequiredMissing, NotAContainer
+from zope.schema.interfaces import RequiredMissing, NotAContainer
 from zope.schema.tests.test_field import FieldTestBase
 
 class ContainerTest(FieldTestBase):
@@ -35,8 +35,8 @@
         field.validate({'a': 1, 'b': 2})
         field.validate(UserDict())
 
-        self.assertRaisesErrorNames(NotAContainer, field.validate, 1)
-        self.assertRaisesErrorNames(NotAContainer, field.validate, True)
+        self.assertRaises(NotAContainer, field.validate, 1)
+        self.assertRaises(NotAContainer, field.validate, True)
 
     def testValidateRequired(self):
         field = self._Field_Factory(title=u'test field', description=u'',
@@ -44,7 +44,7 @@
 
         field.validate('')
 
-        self.assertRaisesErrorNames(RequiredMissing, field.validate, None)
+        self.assertRaises(RequiredMissing, field.validate, None)
 
 
 def test_suite():


=== Zope3/src/zope/schema/tests/test_date.py 1.2 => 1.3 ===
--- Zope3/src/zope/schema/tests/test_date.py:1.2	Fri Jan 16 08:38:20 2004
+++ Zope3/src/zope/schema/tests/test_date.py	Sun Apr 11 06:35:17 2004
@@ -16,7 +16,8 @@
 """
 from unittest import main, makeSuite
 from zope.schema import Date, EnumeratedDate
-from zope.schema import errornames
+from zope.schema.interfaces import RequiredMissing, InvalidValue
+from zope.schema.interfaces import TooSmall, TooBig
 from zope.schema.tests.test_field import FieldTestBase
 from datetime import datetime, date
 
@@ -36,8 +37,7 @@
                                     readonly=False, required=True)
         field.validate(datetime.now().date())
 
-        self.assertRaisesErrorNames(errornames.RequiredMissing,
-                                    field.validate, None)
+        self.assertRaises(RequiredMissing, field.validate, None)
 
     def testValidateMin(self):
         d1 = date(2000,10,1)
@@ -49,8 +49,7 @@
         field.validate(d2)
         field.validate(datetime.now().date())
 
-        self.assertRaisesErrorNames(errornames.TooSmall, field.validate,
-                                    date(2000,9,30))
+        self.assertRaises(TooSmall, field.validate, date(2000,9,30))
 
     def testValidateMax(self):
         d1 = date(2000,10,1)
@@ -62,7 +61,7 @@
         field.validate(d1)
         field.validate(d2)
 
-        self.assertRaisesErrorNames(errornames.TooBig, field.validate, d3)
+        self.assertRaises(TooBig, field.validate, d3)
 
     def testValidateMinAndMax(self):
         d1 = date(2000,10,1)
@@ -79,8 +78,8 @@
         field.validate(d3)
         field.validate(d4)
 
-        self.assertRaisesErrorNames(errornames.TooSmall, field.validate, d1)
-        self.assertRaisesErrorNames(errornames.TooBig, field.validate, d5)
+        self.assertRaises(TooSmall, field.validate, d1)
+        self.assertRaises(TooBig, field.validate, d5)
 
 class EnumeratedDateTest(DateTest):
     """Test the EnumeratedDate Field."""
@@ -98,9 +97,7 @@
         field.validate(d2)
         field.validate(date(2000,10,2))
 
-        self.assertRaisesErrorNames(errornames.InvalidValue,
-                                    field.validate,
-                                    date(2000,10,4))
+        self.assertRaises(InvalidValue, field.validate, date(2000,10,4))
 
 
 def test_suite():


=== Zope3/src/zope/schema/tests/test_datetime.py 1.3 => 1.4 ===
--- Zope3/src/zope/schema/tests/test_datetime.py:1.3	Mon Apr 14 12:13:43 2003
+++ Zope3/src/zope/schema/tests/test_datetime.py	Sun Apr 11 06:35:17 2004
@@ -16,7 +16,8 @@
 """
 from unittest import main, makeSuite
 from zope.schema import Datetime, EnumeratedDatetime
-from zope.schema import errornames
+from zope.schema.interfaces import RequiredMissing, InvalidValue
+from zope.schema.interfaces import TooSmall, TooBig
 from zope.schema.tests.test_field import FieldTestBase
 from datetime import datetime
 
@@ -36,8 +37,7 @@
                                     readonly=False, required=True)
         field.validate(datetime.now())
 
-        self.assertRaisesErrorNames(errornames.RequiredMissing,
-                                    field.validate, None)
+        self.assertRaises(RequiredMissing, field.validate, None)
 
     def testValidateMin(self):
         d1 = datetime(2000,10,1)
@@ -49,8 +49,7 @@
         field.validate(d2)
         field.validate(datetime.now())
 
-        self.assertRaisesErrorNames(errornames.TooSmall, field.validate,
-                                    datetime(2000,9,30))
+        self.assertRaises(TooSmall, field.validate, datetime(2000,9,30))
 
     def testValidateMax(self):
         d1 = datetime(2000,10,1)
@@ -62,7 +61,7 @@
         field.validate(d1)
         field.validate(d2)
 
-        self.assertRaisesErrorNames(errornames.TooBig, field.validate, d3)
+        self.assertRaises(TooBig, field.validate, d3)
 
     def testValidateMinAndMax(self):
         d1 = datetime(2000,10,1)
@@ -79,8 +78,8 @@
         field.validate(d3)
         field.validate(d4)
 
-        self.assertRaisesErrorNames(errornames.TooSmall, field.validate, d1)
-        self.assertRaisesErrorNames(errornames.TooBig, field.validate, d5)
+        self.assertRaises(TooSmall, field.validate, d1)
+        self.assertRaises(TooBig, field.validate, d5)
 
 
 class EnumeratedDatetimeTest(DatetimeTest):
@@ -99,9 +98,7 @@
         field.validate(d2)
         field.validate(datetime(2000,10,2))
 
-        self.assertRaisesErrorNames(errornames.InvalidValue,
-                                    field.validate,
-                                    datetime(2000,10,4))
+        self.assertRaises(InvalidValue, field.validate, datetime(2000,10,4))
 
 
 def test_suite():


=== Zope3/src/zope/schema/tests/test_dictfield.py 1.5 => 1.6 ===
--- Zope3/src/zope/schema/tests/test_dictfield.py:1.5	Sun Aug 17 02:09:20 2003
+++ Zope3/src/zope/schema/tests/test_dictfield.py	Sun Apr 11 06:35:17 2004
@@ -16,7 +16,8 @@
 """
 from unittest import main, makeSuite
 from zope.schema import Dict, Int
-from zope.schema import errornames
+from zope.schema.interfaces import RequiredMissing, WrongContainedType
+from zope.schema.interfaces import TooShort, TooLong
 from zope.schema.tests.test_field import FieldTestBase
 
 class DictTest(FieldTestBase):
@@ -39,8 +40,7 @@
         field.validate({1: 'foo'})
         field.validate({'a': 1})
 
-        self.assertRaisesErrorNames(errornames.RequiredMissing,
-                                    field.validate, None)
+        self.assertRaises(RequiredMissing, field.validate, None)
 
     def testValidateMinValues(self):
         field = Dict(title=u'Dict field',
@@ -50,8 +50,7 @@
         field.validate({1: 'a'})
         field.validate({1: 'a', 2: 'b'})
 
-        self.assertRaisesErrorNames(errornames.TooShort,
-                                    field.validate, {})
+        self.assertRaises(TooShort, field.validate, {})
 
     def testValidateMaxValues(self):
         field = Dict(title=u'Dict field',
@@ -61,10 +60,8 @@
         field.validate({})
         field.validate({1: 'a'})
 
-        self.assertRaisesErrorNames(errornames.TooLong,
-                                    field.validate, {1: 'a', 2: 'b'})
-        self.assertRaisesErrorNames(errornames.TooLong,
-                                    field.validate, {1: 'a', 2: 'b', 3: 'c'})
+        self.assertRaises(TooLong, field.validate, {1: 'a', 2: 'b'})
+        self.assertRaises(TooLong, field.validate, {1: 'a', 2: 'b', 3: 'c'})
 
     def testValidateMinValuesAndMaxValues(self):
         field = Dict(title=u'Dict field',
@@ -74,10 +71,8 @@
         field.validate({1: 'a'})
         field.validate({1: 'a', 2: 'b'})
 
-        self.assertRaisesErrorNames(errornames.TooShort,
-                                    field.validate, {})
-        self.assertRaisesErrorNames(errornames.TooLong,
-                                    field.validate, {1: 'a', 2: 'b', 3: 'c'})
+        self.assertRaises(TooShort, field.validate, {})
+        self.assertRaises(TooLong, field.validate, {1: 'a', 2: 'b', 3: 'c'})
 
     def testValidateValueType(self):
         field = Dict(title=u'Dict field',
@@ -87,12 +82,9 @@
         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': ()} )
+        self.assertRaises(WrongContainedType, field.validate, {1: ''} )
+        self.assertRaises(WrongContainedType, field.validate, {1: 3.14159} )
+        self.assertRaises(WrongContainedType, field.validate, {'a': ()} )
 
     def testValidateKeyTypes(self):
         field = Dict(title=u'Dict field',
@@ -102,12 +94,9 @@
         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'} )
+        self.assertRaises(WrongContainedType, field.validate, {'': 1} )
+        self.assertRaises(WrongContainedType, field.validate, {3.14159: 1} )
+        self.assertRaises(WrongContainedType, field.validate, {(): 'a'} )
 
 
 def test_suite():


=== Zope3/src/zope/schema/tests/test_field.py 1.5 => 1.6 ===
--- Zope3/src/zope/schema/tests/test_field.py:1.5	Mon Jul 28 18:22:32 2003
+++ Zope3/src/zope/schema/tests/test_field.py	Sun Apr 11 06:35:17 2004
@@ -16,20 +16,12 @@
 """
 from unittest import TestCase, TestSuite, main, makeSuite
 from zope.schema import Field, Text, Int
-from zope.schema import errornames
-from zope.schema.interfaces import ValidationError
+from zope.schema.interfaces import ValidationError, RequiredMissing
+from zope.schema.interfaces import ConstraintNotSatisfied
 from zope.testing.doctestunit import DocTestSuite
 
 class FieldTestBase(TestCase):
 
-    def assertRaisesErrorNames(self, error_name, f, *args, **kw):
-        try:
-            f(*args, **kw)
-        except ValidationError, e:
-            self.assertEquals(error_name, e[0])
-            return
-        self.fail('Expected ValidationError')
-
     def test_bind(self):
         field = self._Field_Factory(
             __name__ = 'x',
@@ -66,18 +58,15 @@
         field.validate(0)
         field.validate('')
 
-        self.assertRaisesErrorNames(errornames.RequiredMissing,
-                                    field.validate, None)
+        self.assertRaises(RequiredMissing, field.validate, None)
+
 
 class FieldTest(FieldTestBase):
     """Test generic Field."""
 
-
     _Field_Factory = Field
 
-
     def testSillyDefault(self):
-
         self.assertRaises(ValidationError, Text, default="")
 
     def test__doc__(self):
@@ -118,8 +107,7 @@
                 constraint=isodd)
 
         i.validate(11)
-        self.assertRaisesErrorNames(errornames.ConstraintNotSatisfied,
-                                    i.validate, 10)
+        self.assertRaises(ConstraintNotSatisfied, i.validate, 10)
 
 
 class FieldDefaultBehaviour(TestCase):


=== Zope3/src/zope/schema/tests/test_floatfield.py 1.3 => 1.4 ===
--- Zope3/src/zope/schema/tests/test_floatfield.py:1.3	Mon Apr 14 12:13:43 2003
+++ Zope3/src/zope/schema/tests/test_floatfield.py	Sun Apr 11 06:35:17 2004
@@ -16,7 +16,8 @@
 """
 from unittest import main, makeSuite
 from zope.schema import Float, EnumeratedFloat
-from zope.schema import errornames
+from zope.schema.interfaces import RequiredMissing, InvalidValue
+from zope.schema.interfaces import TooSmall, TooBig
 from zope.schema.tests.test_field import FieldTestBase
 
 class FloatTest(FieldTestBase):
@@ -39,8 +40,7 @@
         field.validate(0.93)
         field.validate(1000.0003)
 
-        self.assertRaisesErrorNames(errornames.RequiredMissing,
-                                    field.validate, None)
+        self.assertRaises(RequiredMissing, field.validate, None)
 
     def testValidateMin(self):
         field = self._Field_Factory(title=u'Float field', description=u'',
@@ -49,8 +49,8 @@
         field.validate(10.6)
         field.validate(20.2)
 
-        self.assertRaisesErrorNames(errornames.TooSmall, field.validate, -9.0)
-        self.assertRaisesErrorNames(errornames.TooSmall, field.validate, 10.4)
+        self.assertRaises(TooSmall, field.validate, -9.0)
+        self.assertRaises(TooSmall, field.validate, 10.4)
 
     def testValidateMax(self):
         field = self._Field_Factory(title=u'Float field', description=u'',
@@ -59,8 +59,8 @@
         field.validate(5.3)
         field.validate(-9.1)
 
-        self.assertRaisesErrorNames(errornames.TooBig, field.validate, 10.51)
-        self.assertRaisesErrorNames(errornames.TooBig, field.validate, 20.7)
+        self.assertRaises(TooBig, field.validate, 10.51)
+        self.assertRaises(TooBig, field.validate, 20.7)
 
     def testValidateMinAndMax(self):
         field = self._Field_Factory(title=u'Float field', description=u'',
@@ -71,10 +71,10 @@
         field.validate(-0.03)
         field.validate(10.0001)
 
-        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)
+        self.assertRaises(TooSmall, field.validate, -10.0)
+        self.assertRaises(TooSmall, field.validate, -1.6)
+        self.assertRaises(TooBig, field.validate, 11.45)
+        self.assertRaises(TooBig, field.validate, 20.02)
 
 
 class EnumeratedFloatTest(FloatTest):
@@ -88,8 +88,7 @@
                                     allowed_values=(0.1, 2.6))
         field.validate(None)
         field.validate(2.6)
-        self.assertRaisesErrorNames(errornames.InvalidValue,
-                                    field.validate, -5.4)
+        self.assertRaises(InvalidValue, field.validate, -5.4)
 
 
 def test_suite():


=== Zope3/src/zope/schema/tests/test_interfacefield.py 1.2 => 1.3 ===
--- Zope3/src/zope/schema/tests/test_interfacefield.py:1.2	Thu May  1 15:35:46 2003
+++ Zope3/src/zope/schema/tests/test_interfacefield.py	Sun Apr 11 06:35:17 2004
@@ -16,7 +16,7 @@
 """
 from unittest import main, makeSuite
 from zope.schema import InterfaceField
-from zope.schema.errornames import RequiredMissing, WrongType
+from zope.schema.interfaces import RequiredMissing, WrongType
 from zope.schema.tests.test_field import FieldTestBase
 from zope.interface import Interface
 
@@ -32,12 +32,12 @@
         field = InterfaceField(title=u'Interface field', description=u'',
                      readonly=False, required=False)
         field.validate(DummyInterface)
-        self.assertRaisesErrorNames(WrongType, field.validate, object())
+        self.assertRaises(WrongType, field.validate, object())
 
     def testValidateRequired(self):
         field = InterfaceField(title=u'Interface field', description=u'',
                      readonly=False, required=True)
-        self.assertRaisesErrorNames(RequiredMissing, field.validate, None)
+        self.assertRaises(RequiredMissing, field.validate, None)
 
 
 def test_suite():


=== Zope3/src/zope/schema/tests/test_intfield.py 1.4 => 1.5 ===
--- Zope3/src/zope/schema/tests/test_intfield.py:1.4	Thu May  1 15:35:46 2003
+++ Zope3/src/zope/schema/tests/test_intfield.py	Sun Apr 11 06:35:17 2004
@@ -16,7 +16,8 @@
 """
 from unittest import main, makeSuite
 from zope.schema import Int, EnumeratedInt
-from zope.schema import errornames
+from zope.schema.interfaces import RequiredMissing, InvalidValue
+from zope.schema.interfaces import TooSmall, TooBig
 from zope.schema.tests.test_field import FieldTestBase
 
 class IntTest(FieldTestBase):
@@ -39,8 +40,7 @@
         field.validate(0)
         field.validate(-1)
 
-        self.assertRaisesErrorNames(errornames.RequiredMissing,
-                                    field.validate, None)
+        self.assertRaises(RequiredMissing, field.validate, None)
 
     def testValidateMin(self):
         field = self._Field_Factory(title=u'Int field', description=u'',
@@ -49,8 +49,8 @@
         field.validate(10)
         field.validate(20)
 
-        self.assertRaisesErrorNames(errornames.TooSmall, field.validate, 9)
-        self.assertRaisesErrorNames(errornames.TooSmall, field.validate, -10)
+        self.assertRaises(TooSmall, field.validate, 9)
+        self.assertRaises(TooSmall, field.validate, -10)
 
     def testValidateMax(self):
         field = self._Field_Factory(title=u'Int field', description=u'',
@@ -59,8 +59,8 @@
         field.validate(5)
         field.validate(9)
 
-        self.assertRaisesErrorNames(errornames.TooBig, field.validate, 11)
-        self.assertRaisesErrorNames(errornames.TooBig, field.validate, 20)
+        self.assertRaises(TooBig, field.validate, 11)
+        self.assertRaises(TooBig, field.validate, 20)
 
     def testValidateMinAndMax(self):
         field = self._Field_Factory(title=u'Int field', description=u'',
@@ -71,10 +71,10 @@
         field.validate(5)
         field.validate(10)
 
-        self.assertRaisesErrorNames(errornames.TooSmall, field.validate, -10)
-        self.assertRaisesErrorNames(errornames.TooSmall, field.validate, -1)
-        self.assertRaisesErrorNames(errornames.TooBig, field.validate, 11)
-        self.assertRaisesErrorNames(errornames.TooBig, field.validate, 20)
+        self.assertRaises(TooSmall, field.validate, -10)
+        self.assertRaises(TooSmall, field.validate, -1)
+        self.assertRaises(TooBig, field.validate, 11)
+        self.assertRaises(TooBig, field.validate, 20)
 
 
 class EnumeratedIntTest(IntTest):
@@ -88,8 +88,7 @@
                                     allowed_values=(-1, 2))
         field.validate(None)
         field.validate(2)
-        self.assertRaisesErrorNames(errornames.InvalidValue,
-                                    field.validate, 4)
+        self.assertRaises(InvalidValue, field.validate, 4)
 
 
 def test_suite():


=== Zope3/src/zope/schema/tests/test_iterablefield.py 1.2 => 1.3 ===
--- Zope3/src/zope/schema/tests/test_iterablefield.py:1.2	Thu May  1 15:35:46 2003
+++ Zope3/src/zope/schema/tests/test_iterablefield.py	Sun Apr 11 06:35:17 2004
@@ -17,8 +17,8 @@
 from UserDict import UserDict, IterableUserDict
 from unittest import main, makeSuite
 from zope.schema import Iterable
-from zope.schema.errornames import RequiredMissing
-from zope.schema.errornames import NotAContainer, NotAnIterator
+from zope.schema.interfaces import RequiredMissing
+from zope.schema.interfaces import NotAContainer, NotAnIterator
 from zope.schema.tests.test_field import FieldTestBase
 
 class IterableTest(FieldTestBase):
@@ -36,9 +36,9 @@
         field.validate({'a': 1, 'b': 2})
         field.validate(IterableUserDict())
 
-        self.assertRaisesErrorNames(NotAContainer, field.validate, 1)
-        self.assertRaisesErrorNames(NotAContainer, field.validate, True)
-        self.assertRaisesErrorNames(NotAnIterator, field.validate, UserDict)
+        self.assertRaises(NotAContainer, field.validate, 1)
+        self.assertRaises(NotAContainer, field.validate, True)
+        self.assertRaises(NotAnIterator, field.validate, UserDict)
 
     def testValidateRequired(self):
         field = self._Field_Factory(title=u'test field', description=u'',
@@ -46,7 +46,7 @@
 
         field.validate('')
 
-        self.assertRaisesErrorNames(RequiredMissing, field.validate, None)
+        self.assertRaises(RequiredMissing, field.validate, None)
 
 
 def test_suite():


=== Zope3/src/zope/schema/tests/test_listfield.py 1.5 => 1.6 ===
--- Zope3/src/zope/schema/tests/test_listfield.py:1.5	Sun Aug 17 02:09:20 2003
+++ Zope3/src/zope/schema/tests/test_listfield.py	Sun Apr 11 06:35:17 2004
@@ -16,7 +16,8 @@
 """
 from unittest import main, makeSuite
 from zope.schema import List, Int
-from zope.schema import errornames
+from zope.schema.interfaces import RequiredMissing, WrongContainedType
+from zope.schema.interfaces import TooShort, TooLong
 from zope.schema.tests.test_field import FieldTestBase
 
 class ListTest(FieldTestBase):
@@ -39,8 +40,7 @@
         field.validate([1, 2])
         field.validate([3,])
 
-        self.assertRaisesErrorNames(errornames.RequiredMissing,
-                                    field.validate, None)
+        self.assertRaises(RequiredMissing, field.validate, None)
 
     def testValidateMinValues(self):
         field = List(title=u'List field', description=u'',
@@ -49,10 +49,8 @@
         field.validate([1, 2])
         field.validate([1, 2, 3])
 
-        self.assertRaisesErrorNames(errornames.TooShort,
-                                    field.validate, [])
-        self.assertRaisesErrorNames(errornames.TooShort,
-                                    field.validate, [1,])
+        self.assertRaises(TooShort, field.validate, [])
+        self.assertRaises(TooShort, field.validate, [1,])
 
     def testValidateMaxValues(self):
         field = List(title=u'List field', description=u'',
@@ -61,10 +59,8 @@
         field.validate([])
         field.validate([1, 2])
 
-        self.assertRaisesErrorNames(errornames.TooLong,
-                                    field.validate, [1, 2, 3, 4])
-        self.assertRaisesErrorNames(errornames.TooLong,
-                                    field.validate, [1, 2, 3])
+        self.assertRaises(TooLong, field.validate, [1, 2, 3, 4])
+        self.assertRaises(TooLong, field.validate, [1, 2, 3])
 
     def testValidateMinValuesAndMaxValues(self):
         field = List(title=u'List field', description=u'',
@@ -74,10 +70,8 @@
         field.validate([1, ])
         field.validate([1, 2])
 
-        self.assertRaisesErrorNames(errornames.TooShort,
-                                    field.validate, [])
-        self.assertRaisesErrorNames(errornames.TooLong,
-                                    field.validate, [1, 2, 3])
+        self.assertRaises(TooShort, field.validate, [])
+        self.assertRaises(TooLong, field.validate, [1, 2, 3])
 
     def testValidateValueTypes(self):
         field = List(title=u'List field', description=u'',
@@ -87,10 +81,8 @@
         field.validate([5,])
         field.validate([2, 3])
 
-        self.assertRaisesErrorNames(errornames.WrongContainedType,
-                                    field.validate, ['',] )
-        self.assertRaisesErrorNames(errornames.WrongContainedType,
-                                    field.validate, [3.14159,] )
+        self.assertRaises(WrongContainedType, field.validate, ['',] )
+        self.assertRaises(WrongContainedType, field.validate, [3.14159,] )
 
 def test_suite():
     return makeSuite(ListTest)


=== Zope3/src/zope/schema/tests/test_objectfield.py 1.3 => 1.4 ===
--- Zope3/src/zope/schema/tests/test_objectfield.py:1.3	Fri Mar 19 07:00:09 2004
+++ Zope3/src/zope/schema/tests/test_objectfield.py	Sun Apr 11 06:35:17 2004
@@ -22,9 +22,10 @@
 
 from zope.interface import Attribute, Interface, implements
 from zope.schema import Object, TextLine
-from zope.schema import errornames
 from zope.schema.fieldproperty import FieldProperty
 from zope.schema.interfaces import ValidationError
+from zope.schema.interfaces import RequiredMissing, WrongContainedType
+from zope.schema.interfaces import WrongType, SchemaNotFullyImplemented
 from zope.schema.tests.test_field import FieldTestBase
 
 _ = MessageIDFactory('zope')
@@ -45,7 +46,7 @@
         default=u"",
         required=False)
         
-    attribute = Attribute("Test attribute, an attribute can't be validated.")    
+    attribute = Attribute("Test attribute, an attribute can't be validated.")
     
 
 class TestClass(object):
@@ -102,15 +103,15 @@
     
 class ObjectTest(FieldTestBase):
     """Test the Object Field."""
-    def getErrors(self, error_name, f, *args, **kw):
+    def getErrors(self, f, *args, **kw):
         try:
             f(*args, **kw)
-        except ValidationError, e:
+        except WrongContainedType, e:
             try:
-                return e[1]
+                return e[0]
             except:  
                 return []
-        self.fail('Expected ValidationError')    
+        self.fail('Expected WrongContainedType Error')    
     
     def makeTestObject(self, **kw):
         kw['schema'] = kw.get('schema', Interface)
@@ -138,7 +139,7 @@
             field = Object(schema=schema)
         for schema in self.invalidSchemas():
             self.assertRaises(ValidationError, Object, schema=schema)
-            self.assertRaisesErrorNames(errornames.WrongType, Object, schema=schema)
+            self.assertRaises(WrongType, Object, schema=schema)
             
     def testValidate(self):
         # this test of the base class is not applicable
@@ -152,8 +153,7 @@
         field = self._Field_Factory(
             title=u'Required field', description=u'',
             readonly=False, required=True)
-        self.assertRaisesErrorNames(errornames.RequiredMissing,
-                                    field.validate, None)
+        self.assertRaises(RequiredMissing, field.validate, None)
         
     def test_validate_TestData(self):
         field = self.makeTestObject(schema=ITestSchema, required=False)
@@ -163,9 +163,9 @@
         field.validate(data)
         data.foo = None
         self.assertRaises(ValidationError, field.validate, data)
-        self.assertRaisesErrorNames(errornames.WrongContainedType, field.validate, data)
-        errors = self.getErrors(errornames.WrongContainedType, field.validate, data)
-        self.assertEqual(str(errors[0]), errornames.RequiredMissing)
+        self.assertRaises(WrongContainedType, field.validate, data)
+        errors = self.getErrors(field.validate, data)
+        self.assertEquals(errors[0], RequiredMissing())
 
     def test_validate_FieldPropertyTestData(self):
         field = self.makeTestObject(schema=ITestSchema, required=False)
@@ -174,15 +174,15 @@
         field = self.makeTestObject(schema=ITestSchema)
         field.validate(data)
         self.assertRaises(ValidationError, setattr, data, 'foo', None)
-        self.assertRaisesErrorNames(errornames.RequiredMissing, setattr, data, 'foo', None)
+        self.assertRaises(RequiredMissing, setattr, data, 'foo', None)
         
     def test_validate_NotFullyImplementedTestData(self):
         field = self.makeTestObject(schema=ITestSchema, required=False)
         data = self.makeNotFullyImplementedTestData()
         self.assertRaises(ValidationError, field.validate, data)
-        self.assertRaisesErrorNames(errornames.WrongContainedType, field.validate, data)
-        errors = self.getErrors(errornames.WrongContainedType, field.validate, data)
-        self.assertEqual(errors[0], errornames.SchemaNotFullyImplemented)
+        self.assertRaises(WrongContainedType, field.validate, data)
+        errors = self.getErrors(field.validate, data)
+        self.assertEquals(errors[0], SchemaNotFullyImplemented())
 
 def test_suite():
     suite = TestSuite()


=== Zope3/src/zope/schema/tests/test_strfield.py 1.3 => 1.4 ===
--- Zope3/src/zope/schema/tests/test_strfield.py:1.3	Mon Apr 14 12:13:43 2003
+++ Zope3/src/zope/schema/tests/test_strfield.py	Sun Apr 11 06:35:17 2004
@@ -16,8 +16,9 @@
 """
 from unittest import TestSuite, main, makeSuite
 from zope.schema import Bytes, BytesLine, Text, TextLine, EnumeratedTextLine
-from zope.schema import errornames
 from zope.schema.interfaces import ValidationError
+from zope.schema.interfaces import RequiredMissing, InvalidValue
+from zope.schema.interfaces import TooShort, TooLong, ConstraintNotSatisfied
 from zope.schema.tests.test_field import FieldTestBase
 
 class StrTest(FieldTestBase):
@@ -40,10 +41,8 @@
             readonly=False, required=True, min_length=1)
         field.validate(self._convert('foo'))
 
-        self.assertRaisesErrorNames(errornames.RequiredMissing,
-                                    field.validate, None)
-        self.assertRaisesErrorNames(errornames.TooShort,
-                                    field.validate, self._convert(''))
+        self.assertRaises(RequiredMissing, field.validate, None)
+        self.assertRaises(TooShort, field.validate, self._convert(''))
 
     def testValidateMinLength(self):
         field = self._Field_Factory(
@@ -53,12 +52,9 @@
         field.validate(self._convert('333'))
         field.validate(self._convert('55555'))
 
-        self.assertRaisesErrorNames(errornames.TooShort,
-                                    field.validate, self._convert(''))
-        self.assertRaisesErrorNames(errornames.TooShort,
-                                    field.validate, self._convert('22'))
-        self.assertRaisesErrorNames(errornames.TooShort,
-                                    field.validate, self._convert('1'))
+        self.assertRaises(TooShort, field.validate, self._convert(''))
+        self.assertRaises(TooShort, field.validate, self._convert('22'))
+        self.assertRaises(TooShort, field.validate, self._convert('1'))
 
     def testValidateMaxLength(self):
         field = self._Field_Factory(
@@ -69,10 +65,8 @@
         field.validate(self._convert('333'))
         field.validate(self._convert('55555'))
 
-        self.assertRaisesErrorNames(errornames.TooLong, field.validate,
-                                    self._convert('666666'))
-        self.assertRaisesErrorNames(errornames.TooLong, field.validate,
-                                    self._convert('999999999'))
+        self.assertRaises(TooLong, field.validate, self._convert('666666'))
+        self.assertRaises(TooLong, field.validate, self._convert('999999999'))
 
     def testValidateMinLengthAndMaxLength(self):
         field = self._Field_Factory(
@@ -85,14 +79,10 @@
         field.validate(self._convert('4444'))
         field.validate(self._convert('55555'))
 
-        self.assertRaisesErrorNames(errornames.TooShort,
-                                    field.validate, self._convert('22'))
-        self.assertRaisesErrorNames(errornames.TooShort,
-                                    field.validate, self._convert('22'))
-        self.assertRaisesErrorNames(errornames.TooLong, field.validate,
-                                    self._convert('666666'))
-        self.assertRaisesErrorNames(errornames.TooLong, field.validate,
-                                    self._convert('999999999'))
+        self.assertRaises(TooShort, field.validate, self._convert('22'))
+        self.assertRaises(TooShort, field.validate, self._convert('22'))
+        self.assertRaises(TooLong, field.validate, self._convert('666666'))
+        self.assertRaises(TooLong, field.validate, self._convert('999999999'))
 
 
 class MultiLine:
@@ -124,7 +114,7 @@
 
     def test_newlines(self):
         field = self._Field_Factory(title=u'Str field')
-        self.assertRaisesErrorNames(errornames.ConstraintNotSatisfied,
+        self.assertRaises(ConstraintNotSatisfied,
                                     field.validate,
                                     self._convert('hello\nworld'))
 
@@ -146,8 +136,7 @@
         field.validate(None)
         field.validate(self._convert('foo'))
 
-        self.assertRaisesErrorNames(errornames.InvalidValue,
-                                    field.validate, self._convert('blah'))
+        self.assertRaises(InvalidValue, field.validate, self._convert('blah'))
 
 
 def test_suite():


=== Zope3/src/zope/schema/tests/test_tuplefield.py 1.6 => 1.7 ===
--- Zope3/src/zope/schema/tests/test_tuplefield.py:1.6	Fri Jan 16 08:38:20 2004
+++ Zope3/src/zope/schema/tests/test_tuplefield.py	Sun Apr 11 06:35:17 2004
@@ -23,7 +23,9 @@
 from zope.interface import implements
 from zope.schema import Field, Sequence, Tuple, Int
 from zope.schema.interfaces import IField
-from zope.schema import errornames
+from zope.schema.interfaces import NotAContainer, RequiredMissing
+from zope.schema.interfaces import WrongContainedType, WrongType
+from zope.schema.interfaces import TooShort, TooLong
 from zope.schema.tests.test_field import FieldTestBase
 
 class SequenceTest(FieldTestBase):
@@ -41,16 +43,14 @@
         field.validate({})
         field.validate([1, 2])
 
-        self.assertRaisesErrorNames(errornames.NotAContainer,
-                                    field.validate, 1)
+        self.assertRaises(NotAContainer, field.validate, 1)
 
     def testValidateRequired(self):
         field = self._Field_Factory(title=u'test field', description=u'',
                                     readonly=False, required=True)
         field.validate([1, 2])
 
-        self.assertRaisesErrorNames(errornames.RequiredMissing,
-                                    field.validate, None)
+        self.assertRaises(RequiredMissing, field.validate, None)
 
 
 class TupleTest(FieldTestBase):
@@ -66,14 +66,10 @@
         field.validate((1, 2))
         field.validate((3,))
 
-        self.assertRaisesErrorNames(errornames.WrongType,
-                                    field.validate, [1, 2, 3])
-        self.assertRaisesErrorNames(errornames.WrongType,
-                                    field.validate, 'abc')
-        self.assertRaisesErrorNames(errornames.WrongType,
-                                    field.validate, 1)
-        self.assertRaisesErrorNames(errornames.WrongType,
-                                    field.validate, {})
+        self.assertRaises(WrongType, field.validate, [1, 2, 3])
+        self.assertRaises(WrongType, field.validate, 'abc')
+        self.assertRaises(WrongType, field.validate, 1)
+        self.assertRaises(WrongType, field.validate, {})
 
     def testValidateRequired(self):
         field = Tuple(title=u'Tuple field', description=u'',
@@ -82,8 +78,7 @@
         field.validate((1, 2))
         field.validate((3,))
 
-        self.assertRaisesErrorNames(errornames.RequiredMissing,
-                                    field.validate, None)
+        self.assertRaises(RequiredMissing, field.validate, None)
 
     def testValidateMinValues(self):
         field = Tuple(title=u'Tuple field', description=u'',
@@ -92,10 +87,8 @@
         field.validate((1, 2))
         field.validate((1, 2, 3))
 
-        self.assertRaisesErrorNames(errornames.TooShort,
-                                    field.validate, ())
-        self.assertRaisesErrorNames(errornames.TooShort,
-                                    field.validate, (1,))
+        self.assertRaises(TooShort, field.validate, ())
+        self.assertRaises(TooShort, field.validate, (1,))
 
     def testValidateMaxValues(self):
         field = Tuple(title=u'Tuple field', description=u'',
@@ -104,10 +97,8 @@
         field.validate(())
         field.validate((1, 2))
 
-        self.assertRaisesErrorNames(errornames.TooLong,
-                                    field.validate, (1, 2, 3, 4))
-        self.assertRaisesErrorNames(errornames.TooLong,
-                                    field.validate, (1, 2, 3))
+        self.assertRaises(TooLong, field.validate, (1, 2, 3, 4))
+        self.assertRaises(TooLong, field.validate, (1, 2, 3))
 
     def testValidateMinValuesAndMaxValues(self):
         field = Tuple(title=u'Tuple field', description=u'',
@@ -117,10 +108,8 @@
         field.validate((1, ))
         field.validate((1, 2))
 
-        self.assertRaisesErrorNames(errornames.TooShort,
-                                    field.validate, ())
-        self.assertRaisesErrorNames(errornames.TooLong,
-                                    field.validate, (1, 2, 3))
+        self.assertRaises(TooShort, field.validate, ())
+        self.assertRaises(TooLong, field.validate, (1, 2, 3))
 
     def testValidateValueTypes(self):
         field = Tuple(title=u'Tuple field', description=u'',
@@ -130,10 +119,8 @@
         field.validate((5,))
         field.validate((2, 3))
 
-        self.assertRaisesErrorNames(errornames.WrongContainedType,
-                                    field.validate, ('',) )
-        self.assertRaisesErrorNames(errornames.WrongContainedType,
-                                    field.validate, (3.14159,) )
+        self.assertRaises(WrongContainedType, field.validate, ('',) )
+        self.assertRaises(WrongContainedType, field.validate, (3.14159,) )
 
     def testCorrectValueType(self):
         # allow value_type of None (XXX)




More information about the Zope3-Checkins mailing list