[Zope-Checkins] CVS: Zope3/lib/python/Schema/tests - testBoolField.py:1.2 testDictField.py:1.3 testField.py:1.6 testFloatField.py:1.3 testIntField.py:1.2 testListField.py:1.5 testStrField.py:1.3 testTupleField.py:1.5
Martijn Faassen
m.faassen@vet.uu.nl
Sun, 14 Jul 2002 17:54:42 -0400
Update of /cvs-repository/Zope3/lib/python/Schema/tests
In directory cvs.zope.org:/tmp/cvs-serv19624/tests
Modified Files:
testBoolField.py testDictField.py testField.py
testFloatField.py testIntField.py testListField.py
testStrField.py testTupleField.py
Log Message:
Cleaned up the unit tests some more; instead of catching ValidationErrors,
the whole 'try..except' is now gone. If validation goes wrong a ValidationError
will propagate, resulting in an error condition in the test and a nice
traceback of exactly the code where this validation was raised, which is
actually what we want rather than the previous situation.
=== Zope3/lib/python/Schema/tests/testBoolField.py 1.1 => 1.2 ===
$Id$
"""
from unittest import TestSuite, main, makeSuite
-from Schema import Bool, ErrorNames, ValidationError
+from Schema import Bool, ErrorNames
from testField import FieldTest
-from Schema.Exceptions import ValidationError
class BoolTest(FieldTest):
"""Test the Bool Field."""
def testValidate(self):
field = Bool(id="field", title='Bool field', description='',
- readonly=0, required=0)
- try:
- field.validate(None)
- field.validate(1)
- field.validate(0)
- field.validate(10)
- field.validate(-10)
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ readonly=0, required=0)
+ field.validate(None)
+ field.validate(1)
+ field.validate(0)
+ field.validate(10)
+ field.validate(-10)
def testValidateRequired(self):
field = Bool(id="field", title='Bool field', description='',
readonly=0, required=1)
- try:
- field.validate(1)
- field.validate(0)
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(1)
+ field.validate(0)
self.assertRaisesErrorNames(ErrorNames.RequiredMissing,
field.validate, None)
@@ -49,12 +42,9 @@
def testAllowedValues(self):
field = Bool(id="field", title='Bool field', description='',
readonly=0, required=0, allowed_values=(0,))
- try:
- field.validate(None)
- field.validate(0)
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ field.validate(None)
+ field.validate(0)
+
self.assertRaisesErrorNames(ErrorNames.InvalidValue,
field.validate, 1)
=== Zope3/lib/python/Schema/tests/testDictField.py 1.2 => 1.3 ===
from unittest import TestSuite, main, makeSuite
from Schema import Dict, Int, Float, ErrorNames
from testField import FieldTest
-from Schema.Exceptions import ValidationError
class DictTest(FieldTest):
"""Test the Dict Field."""
@@ -25,36 +24,29 @@
def testValidate(self):
field = Dict(id="field", title='Dict field',
description='', readonly=0, required=0)
- try:
- field.validate(None)
- field.validate({})
- field.validate({1: 'foo'})
- field.validate({'a': 1})
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ 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)
- try:
- field.validate({})
- field.validate({1: 'foo'})
- field.validate({'a': 1})
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate({})
+ field.validate({1: 'foo'})
+ field.validate({'a': 1})
+
self.assertRaisesErrorNames(ErrorNames.RequiredMissing,
field.validate, None)
def testValidateMinValues(self):
field = Dict(id="field", title='Dict field',
description='', readonly=0, required=0,
- min_values=1)
- try:
- field.validate(None)
- field.validate({1: 'a'})
- field.validate({1: 'a', 2: 'b'})
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ min_values=1)
+ field.validate(None)
+ field.validate({1: 'a'})
+ field.validate({1: 'a', 2: 'b'})
+
self.assertRaisesErrorNames(ErrorNames.NotEnoughElements,
field.validate, {})
@@ -62,12 +54,10 @@
field = Dict(id="field", title='Dict field',
description='', readonly=0, required=0,
max_values=1)
- try:
- field.validate(None)
- field.validate({})
- field.validate({1: 'a'})
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(None)
+ field.validate({})
+ field.validate({1: 'a'})
+
self.assertRaisesErrorNames(ErrorNames.TooManyElements,
field.validate, {1: 'a', 2: 'b'})
self.assertRaisesErrorNames(ErrorNames.TooManyElements,
@@ -77,12 +67,10 @@
field = Dict(id="field", title='Dict field',
description='', readonly=0, required=0,
min_values=1, max_values=2)
- try:
- field.validate(None)
- field.validate({1: 'a'})
- field.validate({1: 'a', 2: 'b'})
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(None)
+ field.validate({1: 'a'})
+ field.validate({1: 'a', 2: 'b'})
+
self.assertRaisesErrorNames(ErrorNames.NotEnoughElements,
field.validate, {})
self.assertRaisesErrorNames(ErrorNames.TooManyElements,
@@ -92,13 +80,10 @@
field = Dict(id="field", title='Dict field',
description='', readonly=0, required=0,
value_types=(Int, Float))
- #try:
field.validate(None)
field.validate({'a': 5.3})
field.validate({'a': 2, 'b': 2.3})
-
- #except ValidationError, e:
- # self.unexpectedValidationError(e)
+
self.assertRaisesErrorNames(ErrorNames.WrongContainedType,
field.validate, {1: ''} )
self.assertRaisesErrorNames(ErrorNames.WrongContainedType,
@@ -108,12 +93,10 @@
field = Dict(id="field", title='Dict field',
description='', readonly=0, required=0,
key_types=(Int, Float))
- try:
- field.validate(None)
- field.validate({5.3: 'a'})
- field.validate({2: 'a', 2.3: 'b'})
- except ValidationError, e:
- self.unexpectedValidsationError(e)
+ 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/Schema/tests/testField.py 1.5 => 1.6 ===
return
self.fail('Expected ValidationError')
- def unexpectedValidationError(self, e):
- self.fail("Expected no ValidationError, but we got %s" % e.error_name)
-
def testValidate(self):
field = Field(id="field", title='Not required field', description='',
readonly=0, required=0)
- try:
- field.validate(None)
- field.validate('foo')
- field.validate(1)
- field.validate(0)
- field.validate('')
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(None)
+ field.validate('foo')
+ field.validate(1)
+ field.validate(0)
+ field.validate('')
def testValidateRequired(self):
field = Field(id="field", title='Required field', description='',
readonly=0, required=1)
- try:
- field.validate('foo')
- field.validate(1)
- field.validate(0)
- field.validate('')
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate('foo')
+ field.validate(1)
+ field.validate(0)
+ field.validate('')
self.assertRaisesErrorNames(ErrorNames.RequiredMissing,
field.validate, None)
=== Zope3/lib/python/Schema/tests/testFloatField.py 1.2 => 1.3 ===
from unittest import TestSuite, main, makeSuite
from Schema import Float, ErrorNames
from testField import FieldTest
-from Schema.Exceptions import ValidationError
class FloatTest(FieldTest):
"""Test the Float Field."""
@@ -25,72 +24,57 @@
def testValidate(self):
field = Float(id="field", title='Float field', description='',
readonly=0, required=0)
- try:
- field.validate(None)
- field.validate(10.0)
- field.validate(0.93)
- field.validate(1000.0003)
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ field.validate(None)
+ field.validate(10.0)
+ field.validate(0.93)
+ field.validate(1000.0003)
+
def testValidateRequired(self):
field = Float(id="field", title='Float field', description='',
readonly=0, required=1)
- try:
- field.validate(10.0)
- field.validate(0.93)
- field.validate(1000.0003)
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(10.0)
+ field.validate(0.93)
+ field.validate(1000.0003)
self.assertRaisesErrorNames(ErrorNames.RequiredMissing,
field.validate, None)
def testAllowedValues(self):
field = Float(id="field", title='Integer field', description='',
readonly=0, required=0, allowed_values=(0.1, 2.6))
- try:
- field.validate(None)
- field.validate(2.6)
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ field.validate(None)
+ field.validate(2.6)
+
self.assertRaisesErrorNames(ErrorNames.InvalidValue,
field.validate, -5.4)
def testValidateMin(self):
field = Float(id="field", title='Float field', description='',
readonly=0, required=0, min=10.5)
- try:
- field.validate(None)
- field.validate(10.6)
- field.validate(20.2)
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(None)
+ field.validate(10.6)
+ field.validate(20.2)
+
self.assertRaisesErrorNames(ErrorNames.TooSmall, field.validate, -9)
self.assertRaisesErrorNames(ErrorNames.TooSmall, field.validate, 10.4)
def testValidateMax(self):
field = Float(id="field", title='Float field', description='',
readonly=0, required=0, max=10.5)
- try:
- field.validate(None)
- field.validate(5.3)
- field.validate(-9.1)
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(None)
+ field.validate(5.3)
+ field.validate(-9.1)
+
self.assertRaisesErrorNames(ErrorNames.TooBig, field.validate, 10.51)
self.assertRaisesErrorNames(ErrorNames.TooBig, field.validate, 20.7)
def testValidateMinAndMax(self):
field = Float(id="field", title='Float field', description='',
readonly=0, required=0, min=-0.6, max=10.1)
- try:
- field.validate(None)
- field.validate(0)
- field.validate(-0.03)
- field.validate(10.0001)
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(None)
+ field.validate(0)
+ field.validate(-0.03)
+ field.validate(10.0001)
+
self.assertRaisesErrorNames(ErrorNames.TooSmall, field.validate, -10)
self.assertRaisesErrorNames(ErrorNames.TooSmall, field.validate, -1.6)
self.assertRaisesErrorNames(ErrorNames.TooBig, field.validate, 11.45)
@@ -99,12 +83,10 @@
def testValidateDecimals(self):
field = Float(id="field", title='Float field', description='',
readonly=0, required=0, decimals=2)
- try:
- field.validate(None)
- field.validate(5.3)
- field.validate(-9.11)
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(None)
+ field.validate(5.3)
+ field.validate(-9.11)
+
self.assertRaisesErrorNames(ErrorNames.TooManyDecimals,
field.validate, 10.511)
self.assertRaisesErrorNames(ErrorNames.TooManyDecimals,
=== Zope3/lib/python/Schema/tests/testIntField.py 1.1 => 1.2 ===
from unittest import TestSuite, main, makeSuite
from Schema import Int, ErrorNames
from testField import FieldTest
-from Schema.Exceptions import ValidationError
class IntTest(FieldTest):
"""Test the Int Field."""
@@ -25,75 +24,58 @@
def testValidate(self):
field = Int(id="field", title='Int field', description='',
readonly=0, required=0)
- try:
- field.validate(None)
- field.validate(10)
- field.validate(0)
- field.validate(-1)
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ field.validate(None)
+ field.validate(10)
+ field.validate(0)
+ field.validate(-1)
+
def testValidateRequired(self):
field = Int(id="field", title='Int field', description='',
- readonly=0, required=1)
- try:
- field.validate(10)
- field.validate(0)
- field.validate(-1)
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ readonly=0, required=1)
+ field.validate(10)
+ field.validate(0)
+ field.validate(-1)
+
self.assertRaisesErrorNames(ErrorNames.RequiredMissing,
field.validate, None)
def testAllowedValues(self):
field = Int(id="field", title='Int field', description='',
readonly=0, required=0, allowed_values=(-1, 2))
- try:
- field.validate(None)
- field.validate(2)
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ field.validate(None)
+ field.validate(2)
+
self.assertRaisesErrorNames(ErrorNames.InvalidValue,
field.validate, 4)
def testValidateMin(self):
field = Int(id="field", title='Int field', description='',
readonly=0, required=0, min=10)
- try:
- field.validate(None)
- field.validate(10)
- field.validate(20)
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(None)
+ field.validate(10)
+ field.validate(20)
+
self.assertRaisesErrorNames(ErrorNames.TooSmall, field.validate, 9)
self.assertRaisesErrorNames(ErrorNames.TooSmall, field.validate, -10)
def testValidateMax(self):
field = Int(id="field", title='Int field', description='',
readonly=0, required=0, max=10)
- try:
- field.validate(None)
- field.validate(5)
- field.validate(9)
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ field.validate(None)
+ field.validate(5)
+ field.validate(9)
+
self.assertRaisesErrorNames(ErrorNames.TooBig, field.validate, 11)
self.assertRaisesErrorNames(ErrorNames.TooBig, field.validate, 20)
def testValidateMinAndMax(self):
field = Int(id="field", title='Int field', description='',
readonly=0, required=0, min=0, max=10)
- try:
- field.validate(None)
- field.validate(0)
- field.validate(5)
- field.validate(10)
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ field.validate(None)
+ field.validate(0)
+ 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)
=== Zope3/lib/python/Schema/tests/testListField.py 1.4 => 1.5 ===
from unittest import TestSuite, main, makeSuite
from Schema import List, Int, Float, ErrorNames
from testField import FieldTest
-from Schema.Exceptions import ValidationError
class ListTest(FieldTest):
"""Test the List Field."""
@@ -25,23 +24,17 @@
def testValidate(self):
field = List(id="field", title='List field', description='',
readonly=0, required=0)
- try:
- field.validate(None)
- field.validate([])
- field.validate([1, 2])
- field.validate([3,])
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ field.validate(None)
+ field.validate([])
+ field.validate([1, 2])
+ field.validate([3,])
+
def testValidateRequired(self):
field = List(id="field", title='List field', description='',
readonly=0, required=1)
- try:
- field.validate([])
- field.validate([1, 2])
- field.validate([3,])
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate([])
+ field.validate([1, 2])
+ field.validate([3,])
self.assertRaisesErrorNames(ErrorNames.RequiredMissing,
field.validate, None)
@@ -49,12 +42,10 @@
def testValidateMinValues(self):
field = List(id="field", title='List field', description='',
readonly=0, required=0, min_values=2)
- try:
- field.validate(None)
- field.validate([1, 2])
- field.validate([1, 2, 3])
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(None)
+ field.validate([1, 2])
+ field.validate([1, 2, 3])
+
self.assertRaisesErrorNames(ErrorNames.NotEnoughElements,
field.validate, [])
self.assertRaisesErrorNames(ErrorNames.NotEnoughElements,
@@ -63,12 +54,10 @@
def testValidateMaxValues(self):
field = List(id="field", title='List field', description='',
readonly=0, required=0, max_values=2)
- try:
- field.validate(None)
- field.validate([])
- field.validate([1, 2])
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(None)
+ field.validate([])
+ field.validate([1, 2])
+
self.assertRaisesErrorNames(ErrorNames.TooManyElements,
field.validate, [1, 2, 3, 4])
self.assertRaisesErrorNames(ErrorNames.TooManyElements,
@@ -77,12 +66,10 @@
def testValidateMinValuesAndMaxValues(self):
field = List(id="field", title='List field', description='',
readonly=0, required=0, min_values=1, max_values=2)
- try:
- field.validate(None)
- field.validate([1, ])
- field.validate([1, 2])
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(None)
+ field.validate([1, ])
+ field.validate([1, 2])
+
self.assertRaisesErrorNames(ErrorNames.NotEnoughElements,
field.validate, [])
self.assertRaisesErrorNames(ErrorNames.TooManyElements,
@@ -91,17 +78,14 @@
def testValidateValueTypes(self):
field = List(id="field", title='List field', description='',
readonly=0, required=0, value_types=(Int, Float))
- try:
- field.validate(None)
- field.validate([5.3,])
- field.validate([2, 2.3])
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(None)
+ field.validate([5.3,])
+ field.validate([2, 2.3])
+
self.assertRaisesErrorNames(ErrorNames.WrongContainedType,
field.validate, ['',] )
self.assertRaisesErrorNames(ErrorNames.WrongContainedType,
field.validate, [2, ''] )
-
def test_suite():
return TestSuite((
=== Zope3/lib/python/Schema/tests/testStrField.py 1.2 => 1.3 ===
from unittest import TestSuite, main, makeSuite
from Schema import Str, ErrorNames
from testField import FieldTest
-from Schema.Exceptions import ValidationError
class StrTest(FieldTest):
"""Test the Str Field."""
@@ -25,21 +24,15 @@
def testValidate(self):
field = Str(id='field', title='Str field', description='',
readonly=0, required=0)
- try:
- field.validate(None)
- field.validate('foo')
- field.validate('')
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ field.validate(None)
+ field.validate('foo')
+ field.validate('')
+
def testValidateRequired(self):
field = Str(id='field', title='Str field', description='',
readonly=0, required=1)
- try:
- field.validate('foo')
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ field.validate('foo')
+
self.assertRaisesErrorNames(ErrorNames.RequiredMissing,
field.validate, None)
self.assertRaisesErrorNames(ErrorNames.RequiredEmptyStr,
@@ -48,25 +41,19 @@
def testAllowedValues(self):
field = Str(id="field", title='Str field', description='',
readonly=0, required=0, allowed_values=('foo', 'bar'))
- try:
- field.validate(None)
- field.validate('foo')
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ field.validate(None)
+ field.validate('foo')
+
self.assertRaisesErrorNames(ErrorNames.InvalidValue,
field.validate, 'blah')
def testValidateMinLength(self):
field = Str(id='field', title='Str field', description='',
readonly=0, required=0, min_length=3)
- try:
- field.validate(None)
- field.validate('333')
- field.validate('55555')
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ field.validate(None)
+ field.validate('333')
+ field.validate('55555')
+
self.assertRaisesErrorNames(ErrorNames.TooShort, field.validate, '')
self.assertRaisesErrorNames(ErrorNames.TooShort, field.validate, '22')
self.assertRaisesErrorNames(ErrorNames.TooShort, field.validate, '1')
@@ -74,14 +61,11 @@
def testValidateMaxLength(self):
field = Str(id='field', title='Str field', description='',
readonly=0, required=0, max_length=5)
- try:
- field.validate(None)
- field.validate('')
- field.validate('333')
- field.validate('55555')
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ field.validate(None)
+ field.validate('')
+ field.validate('333')
+ field.validate('55555')
+
self.assertRaisesErrorNames(ErrorNames.TooLong, field.validate,
'666666')
self.assertRaisesErrorNames(ErrorNames.TooLong, field.validate,
@@ -91,14 +75,11 @@
field = Str(id='field', title='Str field', description='',
readonly=0, required=0, min_length=3, max_length=5)
- try:
- field.validate(None)
- field.validate('333')
- field.validate('4444')
- field.validate('55555')
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ field.validate(None)
+ field.validate('333')
+ field.validate('4444')
+ field.validate('55555')
+
self.assertRaisesErrorNames(ErrorNames.TooShort, field.validate, '22')
self.assertRaisesErrorNames(ErrorNames.TooShort, field.validate, '22')
self.assertRaisesErrorNames(ErrorNames.TooLong, field.validate,
=== Zope3/lib/python/Schema/tests/testTupleField.py 1.4 => 1.5 ===
from unittest import TestSuite, main, makeSuite
from Schema import Tuple, Int, Float, ErrorNames
from testField import FieldTest
-from Schema.Exceptions import ValidationError
class TupleTest(FieldTest):
"""Test the Tuple Field."""
@@ -25,23 +24,17 @@
def testValidate(self):
field = Tuple(id="field", title='Tuple field', description='',
readonly=0, required=0)
- try:
- field.validate(None)
- field.validate(())
- field.validate((1, 2))
- field.validate((3,))
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ field.validate(None)
+ field.validate(())
+ field.validate((1, 2))
+ field.validate((3,))
+
def testValidateRequired(self):
field = Tuple(id="field", title='Tuple field', description='',
readonly=0, required=1)
- try:
- field.validate(())
- field.validate((1, 2))
- field.validate((3,))
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(())
+ field.validate((1, 2))
+ field.validate((3,))
self.assertRaisesErrorNames(ErrorNames.RequiredMissing,
field.validate, None)
@@ -49,12 +42,9 @@
def testValidateMinValues(self):
field = Tuple(id="field", title='Tuple field', description='',
readonly=0, required=0, min_values=2)
- try:
- field.validate(None)
- field.validate((1, 2))
- field.validate((1, 2, 3))
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(None)
+ field.validate((1, 2))
+ field.validate((1, 2, 3))
self.assertRaisesErrorNames(ErrorNames.NotEnoughElements,
field.validate, ())
@@ -64,12 +54,9 @@
def testValidateMaxValues(self):
field = Tuple(id="field", title='Tuple field', description='',
readonly=0, required=0, max_values=2)
- try:
- field.validate(None)
- field.validate(())
- field.validate((1, 2))
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(None)
+ field.validate(())
+ field.validate((1, 2))
self.assertRaisesErrorNames(ErrorNames.TooManyElements,
field.validate, (1, 2, 3, 4))
@@ -79,13 +66,10 @@
def testValidateMinValuesAndMaxValues(self):
field = Tuple(id="field", title='Tuple field', description='',
readonly=0, required=0, min_values=1, max_values=2)
- try:
- field.validate(None)
- field.validate((1, ))
- field.validate((1, 2))
- except ValidationError, e:
- self.unexpectedValidationError(e)
-
+ field.validate(None)
+ field.validate((1, ))
+ field.validate((1, 2))
+
self.assertRaisesErrorNames(ErrorNames.NotEnoughElements,
field.validate, ())
self.assertRaisesErrorNames(ErrorNames.TooManyElements,
@@ -94,17 +78,14 @@
def testValidateValueTypes(self):
field = Tuple(id="field", title='Tuple field', description='',
readonly=0, required=0, value_types=(Int, Float))
- try:
- field.validate(None)
- field.validate((5.3,))
- field.validate((2, 2.3))
- except ValidationError, e:
- self.unexpectedValidationError(e)
+ field.validate(None)
+ field.validate((5.3,))
+ field.validate((2, 2.3))
+
self.assertRaisesErrorNames(ErrorNames.WrongContainedType,
field.validate, ('',) )
self.assertRaisesErrorNames(ErrorNames.WrongContainedType,
field.validate, (2, '') )
-
def test_suite():
return TestSuite((