##// END OF EJS Templates
BUG: Fix wrong command splitting in Interpreter
Gael Varoquaux -
Show More
@@ -708,6 +708,12 class Interpreter(object):
708 708 # the end even though we don't have a line number for it. Fortunately,
709 709 # None does the job nicely.
710 710 linenos.append(None)
711
712 # Same problem at the other end: sometimes the ast tree has its
713 # first complete statement not starting on line 0. In this case
714 # we might miss part of it
715 linenos[0] = 0
716
711 717 lines = python.splitlines()
712 718
713 719 # Create a list of atomic commands.
@@ -5,17 +5,22
5 5 __docformat__ = "restructuredtext en"
6 6
7 7 #-----------------------------------------------------------------------------
8 # Copyright (C) 2008 The IPython Development Team
8 # Copyright (C) 2008-2009 The IPython Development Team
9 9 #
10 10 # Distributed under the terms of the BSD License. The full license is in
11 11 # the file COPYING, distributed as part of this software.
12 12 #-----------------------------------------------------------------------------
13
13
14 14 #-----------------------------------------------------------------------------
15 15 # Imports
16 16 #-----------------------------------------------------------------------------
17 17
18 18 from IPython.kernel.core.interpreter import Interpreter
19 import nose
20
21 #-----------------------------------------------------------------------------
22 # Tests
23 #-----------------------------------------------------------------------------
19 24
20 25 def test_unicode():
21 26 """ Test unicode handling with the interpreter.
@@ -24,3 +29,29 def test_unicode():
24 29 i.execute_python(u'print "ù"')
25 30 i.execute_python('print "ù"')
26 31
32
33 def test_split_commands():
34 """ Test that commands are indeed individually split.
35 """
36 i = Interpreter()
37 test_atoms = [('(1\n + 1)', ),
38 ('1', '1', ),
39 ]
40 for atoms in test_atoms:
41 atoms = [atom.rstrip() + '\n' for atom in atoms]
42 yield nose.tools.assert_equals, i.split_commands(''.join(atoms)), \
43 atoms
44
45
46 def test_long_lines():
47 """ Test for spurious syntax error created by the interpreter.
48 """
49 test_strings = [u'( 1 +\n 1\n )\n\n',
50 u'(1 \n + 1\n )\n\n',
51 ]
52 i = Interpreter()
53 for s in test_strings:
54 yield i.execute, s
55
56
57
General Comments 0
You need to be logged in to leave comments. Login now