[Zope3-checkins] CVS: Zope3/src/zope/interface/tests - dummy.py:1.4 iadapter.py:1.3
Jim Fulton
jim@zope.com
Fri, 18 Apr 2003 18:13:03 -0400
Update of /cvs-repository/Zope3/src/zope/interface/tests
In directory cvs.zope.org:/tmp/cvs-serv8556/src/zope/interface/tests
Modified Files:
dummy.py iadapter.py
Log Message:
In prepration for the upcoming interface changes, I added some
new functions for making interface assertions on instances.
Rather than:
class C:
__class_implements__ = I1, I2
use:
class C:
classProvides(I1, I2)
rather than:
__implements__ = I1, I2
use:
moduleProvides(I1, I2)
rather than:
someinstance.__implements__ = I1, I2
use:
directlyProvides(I1, I2)
Note that interface assertions on persistent objects should be aboided
since the internal representation will change.
Continue to make assertions about the interfaces that class instances
implement the same way:
class C:
__implements__ = I1, I2
I also modified the core software to use the new spellings.
=== Zope3/src/zope/interface/tests/dummy.py 1.3 => 1.4 ===
--- Zope3/src/zope/interface/tests/dummy.py:1.3 Thu Mar 13 13:49:15 2003
+++ Zope3/src/zope/interface/tests/dummy.py Fri Apr 18 18:12:32 2003
@@ -11,9 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+from zope.interface import moduleProvides
from zope.interface.tests.ifoo import IFoo
-__implements__ = IFoo
+moduleProvides(IFoo)
def bar(baz):
pass
=== Zope3/src/zope/interface/tests/iadapter.py 1.2 => 1.3 ===
--- Zope3/src/zope/interface/tests/iadapter.py:1.2 Wed Dec 25 09:15:12 2002
+++ Zope3/src/zope/interface/tests/iadapter.py Fri Apr 18 18:12:32 2003
@@ -19,7 +19,7 @@
import unittest
-from zope.interface import Interface
+from zope.interface import Interface, directlyProvides
class R1(Interface): pass
class R12(Interface): pass
@@ -87,15 +87,15 @@
c = C()
for R in [R2, R3, R4, (R12, R2), (R12, R4)]:
- c.__implements__ = R
+ directlyProvides(c, R)
for P in [P1, P2, P3]:
self.assertEqual(registry.getForObject(c, P), 'R2 P3')
for R in [None, R1, R2, R3, R4, (R12, R2), (R12, R4)]:
- c.__implements__ = R
+ directlyProvides(c, R)
self.assertEqual(registry.getForObject(c, None), None)
- c.__implements__ = R1
+ directlyProvides(c, R1)
for P in [P1, P2, P3]:
self.assertEqual(registry.getForObject(c, P), 'any P3')
@@ -125,7 +125,7 @@
c = C()
for R in [R2, R3, R4, (R12, R2), (R12, R4)]:
- c.__implements__ = R
+ directlyProvides(c, R)
for P in [P1, P2, P3]:
self.assertEqual(
registry.getForObject(c, P,