##// END OF EJS Templates
Add Xfail test on 3.9.8...
Matthias Bussonnier -
Show More
@@ -12,6 +12,7 b' from IPython.core import inputsplitter as isp'
12 from IPython.core.inputtransformer import InputTransformer
12 from IPython.core.inputtransformer import InputTransformer
13 from IPython.core.tests.test_inputtransformer import syntax, syntax_ml
13 from IPython.core.tests.test_inputtransformer import syntax, syntax_ml
14 from IPython.testing import tools as tt
14 from IPython.testing import tools as tt
15 from IPython.testing.decorators import skipif
15
16
16 #-----------------------------------------------------------------------------
17 #-----------------------------------------------------------------------------
17 # Semi-complete examples (also used as tests)
18 # Semi-complete examples (also used as tests)
@@ -321,6 +322,7 b' class InputSplitterTestCase(unittest.TestCase):'
321 self.isp.push(u'\xc3\xa9')
322 self.isp.push(u'\xc3\xa9')
322 self.isp.push(u"u'\xc3\xa9'")
323 self.isp.push(u"u'\xc3\xa9'")
323
324
325 @skipif(sys.version_info[:3] == (3, 9, 8))
324 def test_line_continuation(self):
326 def test_line_continuation(self):
325 """ Test issue #2108."""
327 """ Test issue #2108."""
326 isp = self.isp
328 isp = self.isp
@@ -5,11 +5,14 b' more complex. See test_inputtransformer2_line for tests for line-based'
5 transformations.
5 transformations.
6 """
6 """
7 import string
7 import string
8 import sys
9 from textwrap import dedent
8
10
9 from IPython.core import inputtransformer2 as ipt2
11 import pytest
10 from IPython.core.inputtransformer2 import make_tokens_by_line, _find_assign_op
11
12
12 from textwrap import dedent
13 from IPython.core import inputtransformer2 as ipt2
14 from IPython.core.inputtransformer2 import _find_assign_op, make_tokens_by_line
15 from IPython.testing.decorators import skip_iptest_but_not_pytest
13
16
14 MULTILINE_MAGIC = ("""\
17 MULTILINE_MAGIC = ("""\
15 a = f()
18 a = f()
@@ -256,20 +259,45 b' def test_find_assign_op_dedent():'
256 )
259 )
257
260
258
261
262 examples = [
263 pytest.param("a = 1", "complete", None),
264 pytest.param("for a in range(5):", "incomplete", 4),
265 pytest.param("for a in range(5):\n if a > 0:", "incomplete", 8),
266 pytest.param("raise = 2", "invalid", None),
267 pytest.param("a = [1,\n2,", "incomplete", 0),
268 pytest.param("(\n))", "incomplete", 0),
269 pytest.param("\\\r\n", "incomplete", 0),
270 pytest.param("a = '''\n hi", "incomplete", 3),
271 pytest.param("def a():\n x=1\n global x", "invalid", None),
272 pytest.param(
273 "a \\ ",
274 "invalid",
275 None,
276 marks=pytest.mark.xfail(
277 reason="Bug in python 3.9.8 – bpo 45738",
278 condition=sys.version_info[:3] == (3, 9, 8),
279 raises=SystemError,
280 strict=True,
281 ),
282 ), # Nothing allowed after backslash,
283 pytest.param("1\\\n+2", "complete", None),
284 ]
285
286
287 @skip_iptest_but_not_pytest
288 @pytest.mark.parametrize("code, expected, number", examples)
289 def test_check_complete_param(code, expected, number):
290 cc = ipt2.TransformerManager().check_complete
291 assert cc(code) == (expected, number)
292
293
294 @skip_iptest_but_not_pytest
295 @pytest.mark.xfail(
296 reason="Bug in python 3.9.8 – bpo 45738",
297 condition=sys.version_info[:3] == (3, 9, 8),
298 )
259 def test_check_complete():
299 def test_check_complete():
260 cc = ipt2.TransformerManager().check_complete
300 cc = ipt2.TransformerManager().check_complete
261 assert cc("a = 1") == ("complete", None)
262 assert cc("for a in range(5):") == ("incomplete", 4)
263 assert cc("for a in range(5):\n if a > 0:") == ("incomplete", 8)
264 assert cc("raise = 2") == ("invalid", None)
265 assert cc("a = [1,\n2,") == ("incomplete", 0)
266 assert cc("(\n))") == ("incomplete", 0)
267 assert cc("\\\r\n") == ("incomplete", 0)
268 assert cc("a = '''\n hi") == ("incomplete", 3)
269 assert cc("def a():\n x=1\n global x") == ("invalid", None)
270 assert cc("a \\ ") == ("invalid", None) # Nothing allowed after backslash
271 assert cc("1\\\n+2") == ("complete", None)
272 assert cc("exit") == ("complete", None)
273
301
274 example = dedent("""
302 example = dedent("""
275 if True:
303 if True:
General Comments 0
You need to be logged in to leave comments. Login now