Skip to content

Commit

Permalink
Temporary workarounds for 2.7 and PyPy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Apr 22, 2017
1 parent c4cd075 commit f59dfce
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ python:
install:
- pip install -U pip setuptools
- pip install -U coverage coveralls
# workaround https://github.com/zopefoundation/BTrees/issues/70
- pip install -U --no-binary ":all:" persistent
- pip install -e git+https://github.com/zopefoundation/zope.proxy.git#egg=zope.proxy
- pip install -U -e .[test]
script:
Expand Down
22 changes: 22 additions & 0 deletions src/zope/app/container/browser/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

from zope import component

from zope.security.interfaces import ForbiddenAttribute
from zope.security.proxy import Proxy
from zope.security.checker import Checker, CheckerPublic

def provideAdapter(required, provided, factory):
gsm = component.getGlobalSiteManager()
gsm.registerAdapter(factory, [required], provided, event=False)
Expand All @@ -26,6 +30,24 @@ def setUp(self):
component.getGlobalSiteManager().registerUtility(PrincipalAnnotationUtility(),
IPrincipalAnnotationUtility)

# Temporarily check for and workaround (if needed) the issue with
# security checkers of BTreeItems on PyPy.
# https://github.com/zopefoundation/zope.security/issues/20
import BTrees
tree = BTrees.OOBTree.OOBTree()
tree['a'] = 42

checker = Checker({'items': CheckerPublic})
proxy = Proxy(tree, checker)
items = proxy.items()
try:
list(items)
except ForbiddenAttribute:
checker = Checker({'__iter__': CheckerPublic})
import BTrees._base
BTrees._base._TreeItems.__Security_checker__ = checker
self.addCleanup(lambda: delattr(BTrees._base._TreeItems, '__Security_checker__'))

def publish(self, path, basic=None, form=None):
if basic:
self._testapp.authorization = ('Basic', tuple(basic.split(':')))
Expand Down

0 comments on commit f59dfce

Please sign in to comment.