Comment 6 for bug 98380

Revision history for this message
Glyph Lefkowitz (glyph) wrote :

Here's a patch expressing the above example as a failing doctest. Not the best place for me to have put this, I'm sure, but here it is:

Index: src/zope/interface/adapter.txt
===================================================================
--- src/zope/interface/adapter.txt (revision 98734)
+++ src/zope/interface/adapter.txt (working copy)
@@ -544,3 +544,33 @@
   >>> registry.subscribe([IR1], None, handler)
   >>> registry.subscriptions([IR1], None) == [handler]
   True
+
+
+Bugs
+----
+
+I don't know where to put this, so here you go.
+
+ >>> from zope.interface import Interface, declarations, adapter
+ >>> import types
+ >>> class IFoo(Interface): pass
+ ...
+ >>> class Bar: pass
+ ...
+ >>> class Baz: pass
+ ...
+ >>> def f1(obj): pass
+ ...
+ >>> def f2(obj): pass
+ ...
+ >>> ar = adapter.AdapterRegistry()
+ >>> ar.register([declarations.implementedBy(types.ClassType)], IFoo, '', f1)
+ >>> ar.lookup1(declarations.providedBy(Bar), IFoo) #doctest: +ELLIPSIS
+ <function f1 at ...>
+ >>> declarations.implementedBy(Bar)
+ <implementedBy __main__.Bar>
+ >>> ar.lookup1(declarations.providedBy(Bar), IFoo) #doctest: +ELLIPSIS
+ <function f1 at ...>
+ >>> # Result is f1
+ ...
+