[Zope3-checkins] CVS: Zope3/src/zope/schema/tests - test_interfacefield.py:1.1
   
    Gary Poster
     
    gary@zope.com
       
    Thu, 24 Apr 2003 16:51:59 -0400
    
    
  
Update of /cvs-repository/Zope3/src/zope/schema/tests
In directory cvs.zope.org:/tmp/cvs-serv29673/tests
Added Files:
	test_interfacefield.py 
Log Message:
adding InterfaceField.
=== Added File Zope3/src/zope/schema/tests/test_interfacefield.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
#
##############################################################################
"""
$Id: test_interfacefield.py,v 1.1 2003/04/24 20:51:58 poster Exp $
"""
from unittest import TestSuite, main, makeSuite
from zope.schema import InterfaceField
from zope.schema.errornames import RequiredMissing, WrongType
from zope.schema.tests.test_field import FieldTestBase
from zope.interface import Interface
class DummyInterface(Interface):
    pass
class InterfaceTest(FieldTestBase):
    """Test the Bool Field."""
    _Field_Factory = InterfaceField
    def testValidate(self):
        field = InterfaceField(title=u'Interface field', description=u'',
                     readonly=False, required=False)
        field.validate(DummyInterface)
        self.assertRaisesErrorNames(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)
def test_suite():
    return makeSuite(InterfaceTest)
if __name__ == '__main__':
    main(defaultTest='test_suite')