[Zope3-checkins] CVS: Zope3/src/zope/app/component/tests - test_interfacefield.py:1.4

Steve Alexander steve@cat-box.net
Mon, 6 Jan 2003 13:40:07 -0500


Update of /cvs-repository/Zope3/src/zope/app/component/tests
In directory cvs.zope.org:/tmp/cvs-serv30732/src/zope/app/component/tests

Modified Files:
	test_interfacefield.py 
Log Message:
Gave the interface and interfaces fields a basetype that can be None.
Made widgets display the interface name "Anything" for the catch-all
interface None.
Updated adapter and view configuration schemas to use None as the 
basetype for for_interface


=== Zope3/src/zope/app/component/tests/test_interfacefield.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/component/tests/test_interfacefield.py:1.3	Mon Dec 30 13:43:05 2002
+++ Zope3/src/zope/app/component/tests/test_interfacefield.py	Mon Jan  6 13:39:34 2003
@@ -41,13 +41,23 @@
         class I2(I1): pass
         class I3(I2): pass
 
-        field = InterfaceField(type=I2)
+        field = InterfaceField(basetype=I2)
 
         field.validate(I2)
         field.validate(I3)
 
         self.assertRaises(ValidationError, field.validate, Interface)
         self.assertRaises(ValidationError, field.validate, I1)
+        self.assertRaises(ValidationError, field.validate, None)
+
+    def test_validate_w_none(self):
+        class I1(Interface): pass
+
+        field = InterfaceField(basetype=None)
+
+        field.validate(None)
+        field.validate(Interface)
+        field.validate(I1)
 
 class TestInterfacesField(TestCase):
 
@@ -68,14 +78,23 @@
         class I2(I1): pass
         class I3(I2): pass
 
-        field = InterfacesField(value_type=I2)
+        field = InterfacesField(basetype=I2)
 
         field.validate((I2,))
         field.validate((I3,))
 
         self.assertRaises(ValidationError, field.validate, (Interface,))
         self.assertRaises(ValidationError, field.validate, (I1,))
+        self.assertRaises(ValidationError, field.validate, (None,))
 
+    def test_validate_w_none(self):
+        class I1(Interface): pass
+
+        field = InterfacesField(basetype=None)
+
+        field.validate((None,))
+        field.validate((Interface,))
+        field.validate((I1,))
 
 def test_suite():
     return TestSuite((makeSuite(TestInterfaceField),