##// END OF EJS Templates
Don't dedent on yield, as yield doesn't always end a block
Aaron Meurer -
Show More
@@ -115,8 +115,6 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+yield(\s.*)?$', # normal yield (+ space + other stuff, maybe)
119 r'^\s+yield\([^\)]*\).*$', # wacky yield with immediate open paren
120 r'^\s+pass\s*$', # pass (optionally followed by trailing spaces)
118 r'^\s+pass\s*$', # pass (optionally followed by trailing spaces)
121 r'^\s+break\s*$', # break (optionally followed by trailing spaces)
119 r'^\s+break\s*$', # break (optionally followed by trailing spaces)
122 r'^\s+continue\s*$', # continue (optionally followed by trailing spaces)
120 r'^\s+continue\s*$', # continue (optionally followed by trailing spaces)
@@ -273,20 +273,6 b' class InputSplitterTestCase(unittest.TestCase):'
273 isp.push('if 1:\n return(0)')
273 isp.push('if 1:\n return(0)')
274 self.assertEqual(isp.indent_spaces, 0)
274 self.assertEqual(isp.indent_spaces, 0)
275
275
276 def test_dedent_yield(self):
277 isp = self.isp # shorthand
278 # should NOT cause dedent
279 isp.push('if 1:\n yielding = 4')
280 self.assertEqual(isp.indent_spaces, 4)
281 isp.push('if 1:\n yield 5 + 493')
282 self.assertEqual(isp.indent_spaces, 0)
283 isp.push('if 1:\n yield')
284 self.assertEqual(isp.indent_spaces, 0)
285 isp.push('if 1:\n yield ')
286 self.assertEqual(isp.indent_spaces, 0)
287 isp.push('if 1:\n yield(0)')
288 self.assertEqual(isp.indent_spaces, 0)
289
290 def test_push(self):
276 def test_push(self):
291 isp = self.isp
277 isp = self.isp
292 self.assertTrue(isp.push('x=1'))
278 self.assertTrue(isp.push('x=1'))
General Comments 0
You need to be logged in to leave comments. Login now