Commit 32538fc1 authored by Stefan Behnel's avatar Stefan Behnel

Avoid calling undefined names if IPython import fails.

parent 13349652
...@@ -3,19 +3,26 @@ ...@@ -3,19 +3,26 @@
"""Tests for the Cython magics extension.""" """Tests for the Cython magics extension."""
from __future__ import absolute_import
import os import os
import sys import sys
from contextlib import contextmanager from contextlib import contextmanager
from Cython.Build import IpythonMagic from Cython.Build import IpythonMagic
from Cython.TestUtils import CythonTest
try: try:
from IPython.testing.globalipapp import get_ipython from IPython.testing.globalipapp import get_ipython
from IPython.utils import py3compat from IPython.utils import py3compat
except: except:
# Disable tests and fake helpers for initialisation below.
class _py3compat(object):
def str_to_unicode(self, s):
return s
__test__ = False __test__ = False
ip = None get_ipython = lambda: None
else: py3compat = _py3compat()
ip = get_ipython()
try: try:
# disable IPython history thread to avoid having to clean it up # disable IPython history thread to avoid having to clean it up
...@@ -24,7 +31,8 @@ try: ...@@ -24,7 +31,8 @@ try:
except ImportError: except ImportError:
pass pass
from Cython.TestUtils import CythonTest # Initialise IPython after disabling history thread.
ip = get_ipython()
code = py3compat.str_to_unicode("""\ code = py3compat.str_to_unicode("""\
def f(x): def f(x):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment