Skip to content

Commit

Permalink
Ensure our dependencies match our expactations about C extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
hannosch committed May 4, 2017
1 parent 2d57a3e commit c2ee52e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
4.5.0 (unreleased)
------------------

- Ensure our dependencies match our expactations about C extensions.

4.4.1 (2017-05-04)
------------------
Expand Down
13 changes: 8 additions & 5 deletions src/Acquisition/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import os
import operator
import platform
import sys
import types
import weakref
Expand All @@ -16,6 +17,9 @@
from .interfaces import IAcquirer
from .interfaces import IAcquisitionWrapper

IS_PYPY = getattr(platform, 'python_implementation', lambda: None)() == 'PyPy'
IS_PURE = 'PURE_PYTHON' in os.environ


class Acquired(object):
"Marker for explicit acquisition"
Expand Down Expand Up @@ -938,11 +942,10 @@ def aq_inContextOf(self, o, inner=True):
return False


if 'PURE_PYTHON' not in os.environ: # pragma: no cover
try:
from ._Acquisition import * # NOQA
except ImportError:
pass
if not (IS_PYPY or IS_PURE): # pragma: no cover
# Make sure we can import the C extension of our dependency.
from ExtensionClass import _ExtensionClass # NOQA
from ._Acquisition import * # NOQA

classImplements(Explicit, IAcquirer)
classImplements(ExplicitAcquisitionWrapper, IAcquisitionWrapper)
Expand Down
15 changes: 6 additions & 9 deletions src/Acquisition/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
import gc
import unittest
import sys
import platform
import operator
import os
from doctest import DocTestSuite, DocFileSuite

import ExtensionClass
import Acquisition
from Acquisition import IS_PYPY, IS_PURE


if sys.version_info >= (3,):
Expand All @@ -43,8 +42,6 @@ def unicode(self):
PY2 = True
PY3 = False

py_impl = getattr(platform, 'python_implementation', lambda: None)
PYPY = py_impl() == 'PyPy'
if not hasattr(gc, 'get_threshold'):
# PyPy
gc.get_threshold = lambda: ()
Expand Down Expand Up @@ -1919,7 +1916,7 @@ def test_Basic_gc():
... ignore = gc.collect()
... del a
... removed = gc.collect()
... print(removed > 0 or PYPY)
... print(removed > 0 or IS_PYPY)
removed
True
removed
Expand Down Expand Up @@ -1951,7 +1948,7 @@ def test_Wrapper_gc():
... ignored = gc.collect()
... del a
... removed = gc.collect()
... removed > 0 or PYPY
... removed > 0 or IS_PYPY
removed
True
removed
Expand Down Expand Up @@ -3534,7 +3531,7 @@ def __call__(self, arg, k=None):

self.assertEqual(base.derived(1, k=2), (42, 1, 2))

if not PYPY:
if not IS_PYPY:
# XXX: This test causes certain versions
# of PyPy to segfault (at least 2.6.0-alpha1)
class NotCallable(base_class):
Expand Down Expand Up @@ -3669,8 +3666,8 @@ def test_explicit_proxy_bool(self):
class TestCompilation(unittest.TestCase):

def test_compile(self):
if PYPY or 'PURE_PYTHON' in os.environ:
with self.assertRaises(ImportError):
if IS_PYPY or IS_PURE:
with self.assertRaises((AttributeError, ImportError)):
from Acquisition import _Acquisition
else:
from Acquisition import _Acquisition
Expand Down

0 comments on commit c2ee52e

Please sign in to comment.