[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser/tests - test_directives.py:1.12

Jim Fulton jim@zope.com
Thu, 20 Feb 2003 13:25:00 -0500


Update of /cvs-repository/Zope3/src/zope/app/publisher/browser/tests
In directory cvs.zope.org:/tmp/cvs-serv18984/tests

Modified Files:
	test_directives.py 
Log Message:
Mix-in classes (class attributes) that asserted interfaces (via an
__implements__ attribute) weren't being handled correctly.  The class
__implements__ was overriding necessary assertions made in other
mix-in classes used to generate the final class.


=== Zope3/src/zope/app/publisher/browser/tests/test_directives.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_directives.py:1.11	Tue Feb 11 21:17:28 2003
+++ Zope3/src/zope/app/publisher/browser/tests/test_directives.py	Thu Feb 20 13:24:58 2003
@@ -16,6 +16,8 @@
 import unittest
 from cStringIO import StringIO
 
+from zope.interface import Interface
+
 from zope.configuration.xmlconfig import xmlconfig, XMLConfig
 from zope.configuration.exceptions import ConfigurationError
 from zope.component.tests.views import IC, V1, VZMI, R1, RZMI
@@ -42,6 +44,8 @@
 from zope.app.security.registries.permissionregistry import permissionRegistry
 from zope.app.interfaces.security import IPermissionService
 
+from zope.publisher.interfaces.browser import IBrowserPublisher
+
 tests_path = os.path.join(
     os.path.split(zope.app.publisher.browser.__file__)[0],
     'tests')
@@ -77,6 +81,14 @@
     def __call__(self):
         pass
 
+
+class C_w_implements(NCV):
+
+    __implements__ = Interface
+
+    def index(self):
+        return self
+
 class Test(PlacelessSetup, unittest.TestCase):
 
     def setUp(self):
@@ -268,6 +280,24 @@
         v = getView(ob, 'test', request)
         self.assertEqual(v.index(), 'V1 here')
         self.assertEqual(v.action(), 'done')
+
+    def test_class_w_implements(self):
+        xmlconfig(StringIO(template %
+            """
+            <browser:page
+                  name="test"
+                  class="
+             zope.app.publisher.browser.tests.test_directives.C_w_implements"
+                  for="zope.component.tests.views.IC"
+                  attribute="index"
+                  permission="zope.Public"
+                  />
+            """
+            ))
+
+        v = getView(ob, 'test', request)
+        self.assertEqual(v.index(), v)
+        self.assert_(IBrowserPublisher.isImplementedBy(v))
 
     def testIncompleteProtectedPageNoPermission(self):
         self.assertRaises(