diff options
author | Jason Madden <jamadden@gmail.com> | 2015-05-28 18:13:54 -0500 |
---|---|---|
committer | Jason Madden <jamadden@gmail.com> | 2015-05-28 18:13:54 -0500 |
commit | f9e5240ce788cacbf76e89d48722538727ef0b1e (patch) | |
tree | 68a82cc856a644c9ffb032866ea409b502487642 | |
parent | 0018bc9c478421537b2c7364e63c98ac55155363 (diff) | |
download | zope-proxy-f9e5240ce788cacbf76e89d48722538727ef0b1e.tar.gz |
Workaround bizarre bug in PyPy 2.5.0 where proxys around types cannot be correctly hashed.
-rw-r--r-- | src/zope/proxy/tests/test_proxy.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/zope/proxy/tests/test_proxy.py b/src/zope/proxy/tests/test_proxy.py index dd11b54..c4a7574 100644 --- a/src/zope/proxy/tests/test_proxy.py +++ b/src/zope/proxy/tests/test_proxy.py @@ -719,20 +719,34 @@ class PyProxyBaseTestCase(unittest.TestCase): class IFoo(Interface): pass impl_before = list(implementedBy(builtin_type)) + classImplements(builtin_type, IFoo) builtin = builtin_type() self.assertTrue(IFoo in list(providedBy(builtin))) + self.assertTrue(IFoo in list(implementedBy(builtin_type))) try: - proxy_instance = proxy_class(builtin) - provided_instance = providedBy(proxy_instance) - proxy_type = proxy_class(builtin_type) - provided_type = implementedBy(proxy_type) # The asserts must be before we remove the interface # because there's a single object that gets mutated + + proxy_instance = proxy_class(builtin) + provided_instance = providedBy(proxy_instance) self.assertTrue(IFoo in list(provided_instance)) - self.assertTrue(IFoo in list(provided_type)) + + # XXX: PyPy 2.5.0 has a bug where proxys around types + # aren't correctly hashable, which breaks this part of the + # test. This is fixed in 2.5.1, but as of 2015-05-28, + # TravisCI still uses 2.5.0. + proxy_type = proxy_class(builtin_type) + from zope.interface.declarations import BuiltinImplementationSpecifications + if proxy_type in BuiltinImplementationSpecifications \ + and BuiltinImplementationSpecifications.get(proxy_type, self) is not self: + provided_type = implementedBy(proxy_type) + self.assertTrue(IFoo in list(provided_type)) + else: + import sys + self.assertEqual((2,5,0), sys.pypy_version_info[:3]) finally: classImplementsOnly(builtin_type, *impl_before) |