Show More
@@ -115,7 +115,9 b" dedent_re = re.compile('|'.join([" | |||||
115 | r'^\s+raise\([^\)]*\).*$', # wacky raise with immediate open paren |
|
115 | r'^\s+raise\([^\)]*\).*$', # wacky raise with immediate open paren | |
116 | r'^\s+return(\s.*)?$', # normal return (+ space + other stuff, maybe) |
|
116 | r'^\s+return(\s.*)?$', # normal return (+ space + other stuff, maybe) | |
117 | r'^\s+return\([^\)]*\).*$', # wacky return with immediate open paren |
|
117 | r'^\s+return\([^\)]*\).*$', # wacky return with immediate open paren | |
118 | r'^\s+pass\s*$' # pass (optionally followed by trailing spaces) |
|
118 | r'^\s+pass\s*$', # pass (optionally followed by trailing spaces) | |
|
119 | r'^\s+break\s*$', # break (optionally followed by trailing spaces) | |||
|
120 | r'^\s+continue\s*$', # continue (optionally followed by trailing spaces) | |||
119 | ])) |
|
121 | ])) | |
120 | ini_spaces_re = re.compile(r'^([ \t\r\f\v]+)') |
|
122 | ini_spaces_re = re.compile(r'^([ \t\r\f\v]+)') | |
121 |
|
123 | |||
@@ -369,7 +371,7 b' class InputSplitter(object):' | |||||
369 | self.code, self._is_complete = None, None |
|
371 | self.code, self._is_complete = None, None | |
370 |
|
372 | |||
371 | # Honor termination lines properly |
|
373 | # Honor termination lines properly | |
372 |
if source. |
|
374 | if source.endswith('\\\n'): | |
373 | return False |
|
375 | return False | |
374 |
|
376 | |||
375 | self._update_indent(lines) |
|
377 | self._update_indent(lines) |
@@ -227,6 +227,26 b' class InputSplitterTestCase(unittest.TestCase):' | |||||
227 | isp.push('if 1:\n pass ') |
|
227 | isp.push('if 1:\n pass ') | |
228 | self.assertEqual(isp.indent_spaces, 0) |
|
228 | self.assertEqual(isp.indent_spaces, 0) | |
229 |
|
229 | |||
|
230 | def test_dedent_break(self): | |||
|
231 | isp = self.isp # shorthand | |||
|
232 | # should NOT cause dedent | |||
|
233 | isp.push('while 1:\n breaks = 5') | |||
|
234 | self.assertEqual(isp.indent_spaces, 4) | |||
|
235 | isp.push('while 1:\n break') | |||
|
236 | self.assertEqual(isp.indent_spaces, 0) | |||
|
237 | isp.push('while 1:\n break ') | |||
|
238 | self.assertEqual(isp.indent_spaces, 0) | |||
|
239 | ||||
|
240 | def test_dedent_continue(self): | |||
|
241 | isp = self.isp # shorthand | |||
|
242 | # should NOT cause dedent | |||
|
243 | isp.push('while 1:\n continues = 5') | |||
|
244 | self.assertEqual(isp.indent_spaces, 4) | |||
|
245 | isp.push('while 1:\n continue') | |||
|
246 | self.assertEqual(isp.indent_spaces, 0) | |||
|
247 | isp.push('while 1:\n continue ') | |||
|
248 | self.assertEqual(isp.indent_spaces, 0) | |||
|
249 | ||||
230 | def test_dedent_raise(self): |
|
250 | def test_dedent_raise(self): | |
231 | isp = self.isp # shorthand |
|
251 | isp = self.isp # shorthand | |
232 | # should NOT cause dedent |
|
252 | # should NOT cause dedent | |
@@ -351,6 +371,22 b' class InputSplitterTestCase(unittest.TestCase):' | |||||
351 | self.isp.push(u'\xc3\xa9') |
|
371 | self.isp.push(u'\xc3\xa9') | |
352 | self.isp.push(u"u'\xc3\xa9'") |
|
372 | self.isp.push(u"u'\xc3\xa9'") | |
353 |
|
373 | |||
|
374 | def test_line_continuation(self): | |||
|
375 | """ Test issue #2108.""" | |||
|
376 | isp = self.isp | |||
|
377 | # A blank line after a line continuation should not accept more | |||
|
378 | isp.push("1 \\\n\n") | |||
|
379 | self.assertFalse(isp.push_accepts_more()) | |||
|
380 | # Whitespace after a \ is a SyntaxError. The only way to test that | |||
|
381 | # here is to test that push doesn't accept more (as with | |||
|
382 | # test_syntax_error() above). | |||
|
383 | isp.push(r"1 \ ") | |||
|
384 | self.assertFalse(isp.push_accepts_more()) | |||
|
385 | # Even if the line is continuable (c.f. the regular Python | |||
|
386 | # interpreter) | |||
|
387 | isp.push(r"(1 \ ") | |||
|
388 | self.assertFalse(isp.push_accepts_more()) | |||
|
389 | ||||
354 | class InteractiveLoopTestCase(unittest.TestCase): |
|
390 | class InteractiveLoopTestCase(unittest.TestCase): | |
355 | """Tests for an interactive loop like a python shell. |
|
391 | """Tests for an interactive loop like a python shell. | |
356 | """ |
|
392 | """ |
@@ -9,7 +9,7 b' Welcome to IPython. Our full documentation is available on `our website' | |||||
9 | <http://ipython.org/documentation.html>`_; if you downloaded a built source |
|
9 | <http://ipython.org/documentation.html>`_; if you downloaded a built source | |
10 | distribution the ``docs/source`` directory contains the plaintext version of |
|
10 | distribution the ``docs/source`` directory contains the plaintext version of | |
11 | these manuals. If you have Sphinx installed, you can build them by typing |
|
11 | these manuals. If you have Sphinx installed, you can build them by typing | |
12 | ``make html`` for local browsing. |
|
12 | ``cd docs; make html`` for local browsing. | |
13 |
|
13 | |||
14 |
|
14 | |||
15 | Dependencies and supported Python versions |
|
15 | Dependencies and supported Python versions |
General Comments 0
You need to be logged in to leave comments.
Login now