Show More
@@ -434,7 +434,7 b' class InputSplitter(object):' | |||
|
434 | 434 | #print 'Full dedent in text',self.source # dbg |
|
435 | 435 | full_dedent = True |
|
436 | 436 | |
|
437 | if line[-1] == ':': | |
|
437 | if line.rstrip()[-1] == ':': | |
|
438 | 438 | indent_spaces += 4 |
|
439 | 439 | elif dedent_re.match(line): |
|
440 | 440 | indent_spaces -= 4 |
@@ -201,6 +201,21 b' class InputSplitterTestCase(unittest.TestCase):' | |||
|
201 | 201 | isp.push(" x = (1+\n 2)") |
|
202 | 202 | self.assertEqual(isp.indent_spaces, 4) |
|
203 | 203 | |
|
204 | def test_indent4(self): | |
|
205 | # In cell mode, inputs must be fed in whole blocks, so skip this test | |
|
206 | if self.isp.input_mode == 'cell': return | |
|
207 | ||
|
208 | isp = self.isp | |
|
209 | # whitespace after ':' should not screw up indent level | |
|
210 | isp.push('if 1: \n x=1') | |
|
211 | self.assertEqual(isp.indent_spaces, 4) | |
|
212 | isp.push('y=2\n') | |
|
213 | self.assertEqual(isp.indent_spaces, 0) | |
|
214 | isp.push('if 1:\t\n x=1') | |
|
215 | self.assertEqual(isp.indent_spaces, 4) | |
|
216 | isp.push('y=2\n') | |
|
217 | self.assertEqual(isp.indent_spaces, 0) | |
|
218 | ||
|
204 | 219 | def test_dedent_pass(self): |
|
205 | 220 | isp = self.isp # shorthand |
|
206 | 221 | # should NOT cause dedent |
General Comments 0
You need to be logged in to leave comments.
Login now