Skip to content

Commit

Permalink
Workaround broken test on Python 3 with cython.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Jun 26, 2018
1 parent fa77efa commit 5ced9a2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ install:
- pip install -U coveralls coverage
- pip install -U -e ".[test]"

cache: pip

cache:
pip: true
directories:
- $HOME/.ccache

before_cache:
- rm -f $HOME/.cache/pip/log/debug.log
4 changes: 4 additions & 0 deletions src/nti/externalization/externalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,15 @@ def _to_external_object_state(obj, state, top_level=False, decorate=True,
# NOTE: we cannot try to to-string the object, it may try to call back to us
# NOTE2: In case we encounter a proxy (zope.container.contained.ContainedProxy)
# the type(o) is not reliable. Only the __class__ is.
# NOTE3: On Cython 0.28.3 on Python 3, this actually fails.
# We expect to see this bug fixed before we release.
# https://github.com/cython/cython/issues/2425
logger.exception("Exception externalizing component object %s/%s",
type(obj), obj.__class__)
return state.catch_component_action(obj, t)



def toExternalObject(obj,
name=_NotGiven,
registry=component,
Expand Down
19 changes: 15 additions & 4 deletions src/nti/externalization/tests/test_externalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from nti.testing.matchers import is_false

from . import ExternalizationLayerTest
from .._compat import PY3
from .._compat import PURE_PYTHON
from ..datastructures import ExternalizableDictionaryMixin
from ..datastructures import ExternalizableInstanceDict
from ..externalization import NonExternalizableObjectError
Expand Down Expand Up @@ -189,10 +191,19 @@ class Raises(object):
def toExternalObject(self, **unused_kwargs):
assert False

assert_that(toExternalObject([Raises()],
catch_components=(AssertionError,),
catch_component_action=catch_replace_action),
is_([catch_replace_action(None, None)]))
if PY3 and not PURE_PYTHON:
# Cython 0.28.3 has a bug on Python 3.
# https://github.com/cython/cython/issues/2425
assert_that(calling(toExternalObject).with_args(
[Raises()],
catch_components=(AssertionError,),
catch_component_action=catch_replace_action),
raises(AssertionError))
else:
assert_that(toExternalObject([Raises()],
catch_components=(AssertionError,),
catch_component_action=catch_replace_action),
is_([catch_replace_action(None, None)]))

# Default doesn't catch
assert_that(calling(toExternalObject).with_args([Raises()]),
Expand Down

0 comments on commit 5ced9a2

Please sign in to comment.