summaryrefslogtreecommitdiff
path: root/src/zope/interface/tests/test_adapter.py
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2020-01-28 16:04:31 -0600
committerJason Madden <jamadden@gmail.com>2020-01-28 16:04:31 -0600
commit97997956d1a17a0cfb064dfe0487291e8f8ee181 (patch)
treea491a49d49388774f3b04ced86985578e6be4bac /src/zope/interface/tests/test_adapter.py
parent489328a5afc1430a064db2dba7a7a408591789f9 (diff)
downloadzope-interface-issue162.tar.gz
The _empty singleton has no-op subscribe/unsubscribe methods.issue162
Turns out they can be called in some very strange error cases. See #162 and #163 for details. This should fix #162 (at least the provided test case, five.intid, passes now). It also does enough work on #163 that (a) the test can be written and run in pure-python mode, which was needed to debug it and (b) five.intid runs in pure-python mode (well, with a bunch of other small hacks to Acquisition, ExtensionClass, DocumentTemplate and AccessControl), but I won't claim that it fully fixes #163. For one thing, there are no specific tests. For another, I see more such differences.
Diffstat (limited to 'src/zope/interface/tests/test_adapter.py')
-rw-r--r--src/zope/interface/tests/test_adapter.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/zope/interface/tests/test_adapter.py b/src/zope/interface/tests/test_adapter.py
index 25cb4bb..6703a48 100644
--- a/src/zope/interface/tests/test_adapter.py
+++ b/src/zope/interface/tests/test_adapter.py
@@ -997,6 +997,24 @@ class AdapterLookupBaseTests(unittest.TestCase):
result = alb.queryMultiAdapter((foo,), IBar, default=_default)
self.assertTrue(result is _default)
+ def test_queryMultiAdapter_errors_on_attribute_access(self):
+ # Which leads to using the _empty singleton as "requires"
+ # argument. See https://github.com/zopefoundation/zope.interface/issues/162
+ from zope.interface.interface import InterfaceClass
+ IFoo = InterfaceClass('IFoo')
+ registry = self._makeRegistry()
+ alb = self._makeOne(registry)
+ alb.lookup = alb._uncached_lookup
+ class UnexpectedErrorsLikeAcquisition(object):
+
+ def __getattribute__(self, name):
+ raise RuntimeError("Acquisition does this. Ha-ha!")
+
+ result = alb.queryMultiAdapter(
+ (UnexpectedErrorsLikeAcquisition(),),
+ IFoo,
+ )
+
def test_queryMultiAdaptor_factory_miss(self):
from zope.interface.declarations import implementer
from zope.interface.interface import InterfaceClass