[Checkins] SVN: zope.schema/branches/tseaver-test_cleanup/src/zope/schema/tests/test_ Coalesce out-of-module tests.
Tres Seaver
cvs-admin at zope.org
Thu Apr 26 22:27:27 UTC 2012
Log message for revision 125313:
Coalesce out-of-module tests.
Changed:
U zope.schema/branches/tseaver-test_cleanup/src/zope/schema/tests/test__bootstrapfields.py
D zope.schema/branches/tseaver-test_cleanup/src/zope/schema/tests/test_containerfield.py
D zope.schema/branches/tseaver-test_cleanup/src/zope/schema/tests/test_iterablefield.py
-=-
Modified: zope.schema/branches/tseaver-test_cleanup/src/zope/schema/tests/test__bootstrapfields.py
===================================================================
--- zope.schema/branches/tseaver-test_cleanup/src/zope/schema/tests/test__bootstrapfields.py 2012-04-26 22:27:19 UTC (rev 125312)
+++ zope.schema/branches/tseaver-test_cleanup/src/zope/schema/tests/test__bootstrapfields.py 2012-04-26 22:27:24 UTC (rev 125313)
@@ -358,6 +358,15 @@
def _makeOne(self, *args, **kw):
return self._getTargetClass()(*args, **kw)
+ def test_validate_not_required(self):
+ field = self._makeOne(required=False)
+ field.validate(None)
+
+ def test_validate_required(self):
+ from zope.schema.interfaces import RequiredMissing
+ field = self._makeOne()
+ self.assertRaises(RequiredMissing, field.validate, None)
+
def test__validate_not_collection_not_iterable(self):
from zope.schema._bootstrapinterfaces import NotAContainer
cont = self._makeOne()
Deleted: zope.schema/branches/tseaver-test_cleanup/src/zope/schema/tests/test_containerfield.py
===================================================================
--- zope.schema/branches/tseaver-test_cleanup/src/zope/schema/tests/test_containerfield.py 2012-04-26 22:27:19 UTC (rev 125312)
+++ zope.schema/branches/tseaver-test_cleanup/src/zope/schema/tests/test_containerfield.py 2012-04-26 22:27:24 UTC (rev 125313)
@@ -1,58 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Container field tests
-"""
-import unittest
-
-from zope.schema.tests.test_field import FieldTestBase
-
-class ContainerTest(unittest.TestCase, FieldTestBase):
- """Test the Container Field."""
-
- def _getTargetClass(self):
- from zope.schema import Container
- return Container
-
- def testValidate(self):
- try:
- from UserDict import UserDict
- except ImportError: #pragma NO COVER python3
- from collections import UserDict
- from zope.schema._compat import u
- from zope.schema.interfaces import NotAContainer
- field = self._makeOne(title=u('test field'), description=u(''),
- readonly=False, required=False)
- field.validate(None)
- field.validate('')
- field.validate('abc')
- field.validate([1, 2, 3])
- field.validate({'a': 1, 'b': 2})
- field.validate(UserDict())
-
- self.assertRaises(NotAContainer, field.validate, 1)
- self.assertRaises(NotAContainer, field.validate, True)
-
- def testValidateRequired(self):
- from zope.schema._compat import u
- from zope.schema.interfaces import RequiredMissing
- field = self._makeOne(title=u('test field'), description=u(''),
- readonly=False, required=True)
- field.validate('')
- self.assertRaises(RequiredMissing, field.validate, None)
-
-
-def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(ContainerTest),
- ))
Deleted: zope.schema/branches/tseaver-test_cleanup/src/zope/schema/tests/test_iterablefield.py
===================================================================
--- zope.schema/branches/tseaver-test_cleanup/src/zope/schema/tests/test_iterablefield.py 2012-04-26 22:27:19 UTC (rev 125312)
+++ zope.schema/branches/tseaver-test_cleanup/src/zope/schema/tests/test_iterablefield.py 2012-04-26 22:27:24 UTC (rev 125313)
@@ -1,65 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Iterable field tests
-"""
-import unittest
-
-from zope.schema.tests.test_field import FieldTestBase
-
-
-class IterableTest(unittest.TestCase, FieldTestBase):
- """Test the Iterable Field."""
-
- def _getTargetClass(self):
- from zope.schema import Iterable
- return Iterable
-
- def testValidate(self):
- try:
- from UserDict import UserDict
- except ImportError: #pragma NO COVER python3
- from collections import UserDict
- IterableUserDict = UserDict
- else: #pragma NO COVER python2
- from UserDict import IterableUserDict
- from zope.schema._compat import u
- from zope.schema.interfaces import NotAContainer
- from zope.schema.interfaces import NotAnIterator
- field = self._makeOne(title=u('test field'), description=u(''),
- readonly=False, required=False)
- field.validate(None)
- field.validate('')
- field.validate('abc')
- field.validate([1, 2, 3])
- field.validate({'a': 1, 'b': 2})
- field.validate(IterableUserDict())
-
- self.assertRaises(NotAContainer, field.validate, 1)
- self.assertRaises(NotAContainer, field.validate, True)
- self.assertRaises(NotAnIterator, field.validate, UserDict)
-
- def testValidateRequired(self):
- from zope.schema._compat import u
- from zope.schema.interfaces import RequiredMissing
- field = self._makeOne(title=u('test field'), description=u(''),
- readonly=False, required=True)
- field.validate('')
- self.assertRaises(RequiredMissing, field.validate, None)
-
-
-def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(IterableTest),
- ))
-
More information about the checkins
mailing list