diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2017-10-01 11:54:14 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2017-10-01 11:54:14 +0200 |
commit | 32538fc162be830bf01ff96e43a020bc4924a1ee (patch) | |
tree | db04041db8f08669cf7473f74aea0651700d0b7d | |
parent | 133496521e6e27c6541efe43afda177241dd21b6 (diff) | |
download | cython-32538fc162be830bf01ff96e43a020bc4924a1ee.tar.gz |
Avoid calling undefined names if IPython import fails.0.27.1
-rw-r--r-- | Cython/Build/Tests/TestIpythonMagic.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Cython/Build/Tests/TestIpythonMagic.py b/Cython/Build/Tests/TestIpythonMagic.py index 5de27aa19..5dff3a7f9 100644 --- a/Cython/Build/Tests/TestIpythonMagic.py +++ b/Cython/Build/Tests/TestIpythonMagic.py @@ -3,19 +3,26 @@ """Tests for the Cython magics extension.""" +from __future__ import absolute_import + import os import sys from contextlib import contextmanager from Cython.Build import IpythonMagic +from Cython.TestUtils import CythonTest try: from IPython.testing.globalipapp import get_ipython from IPython.utils import py3compat except: + # Disable tests and fake helpers for initialisation below. + class _py3compat(object): + def str_to_unicode(self, s): + return s + __test__ = False - ip = None -else: - ip = get_ipython() + get_ipython = lambda: None + py3compat = _py3compat() try: # disable IPython history thread to avoid having to clean it up @@ -24,7 +31,8 @@ try: except ImportError: pass -from Cython.TestUtils import CythonTest +# Initialise IPython after disabling history thread. +ip = get_ipython() code = py3compat.str_to_unicode("""\ def f(x): |