From ae1f2befd1372f37562420aab9d87a0a625ba58d 2014-01-10 01:02:36 From: Thomas Kluyver Date: 2014-01-10 01:02:36 Subject: [PATCH] Merge pull request #4758 from takluyver/testing-py34 Python 3.4 fixes --- diff --git a/IPython/nbconvert/filters/tests/test_citation.py b/IPython/nbconvert/filters/tests/test_citation.py index 7f068c2..f36c9ac 100644 --- a/IPython/nbconvert/filters/tests/test_citation.py +++ b/IPython/nbconvert/filters/tests/test_citation.py @@ -11,6 +11,7 @@ #----------------------------------------------------------------------------- from ..citation import citation2latex +from nose.tools import assert_equal #----------------------------------------------------------------------------- # Tests @@ -51,8 +52,8 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit def test_citation2latex(): """Are citations parsed properly?""" try: - import lxml + from lxml import html #analysis:ignore except ImportError: - assert test_md == citation2latex(test_md) + assert_equal(test_md, citation2latex(test_md)) else: - assert test_md_parsed == citation2latex(test_md) + assert_equal(test_md_parsed, citation2latex(test_md)) diff --git a/IPython/utils/tests/test_text.py b/IPython/utils/tests/test_text.py index 5a9eb21..96e714a 100644 --- a/IPython/utils/tests/test_text.py +++ b/IPython/utils/tests/test_text.py @@ -16,6 +16,7 @@ from __future__ import print_function import os import math import random +import sys import nose.tools as nt @@ -108,7 +109,12 @@ def eval_formatter_no_slicing_check(f): s = f.format('{stuff[slice(1,4)]}', **ns) nt.assert_equal(s, 'ell') - nt.assert_raises(SyntaxError, f.format, "{a[:]}") + if sys.version_info >= (3, 4): + # String formatting has changed in Python 3.4, so this now works. + s = f.format("{a[:]}", a=[1, 2]) + nt.assert_equal(s, "[1, 2]") + else: + nt.assert_raises(SyntaxError, f.format, "{a[:]}") def test_eval_formatter(): f = text.EvalFormatter() diff --git a/IPython/utils/text.py b/IPython/utils/text.py index 3c7a5a1..b57895b 100644 --- a/IPython/utils/text.py +++ b/IPython/utils/text.py @@ -517,6 +517,9 @@ class EvalFormatter(Formatter): v = eval(name, kwargs) return v, name +#XXX: As of Python 3.4, the format string parsing no longer splits on a colon +# inside [], so EvalFormatter can handle slicing. Once we only support 3.4 and +# above, it should be possible to remove FullEvalFormatter. @skip_doctest_py3 class FullEvalFormatter(Formatter):