Collapse else: if: ... into elif:

This commit is contained in:
Mark Dickinson 2010-06-30 08:32:11 +00:00
parent 719e4e3ba5
commit 8d6d760422
2 changed files with 32 additions and 1 deletions

View file

@ -64,6 +64,24 @@ def h():
class Foo: pass
"""
elif1 = """\
if cond1:
suite1
elif cond2:
suite2
else:
suite3
"""
elif2 = """\
if cond1:
suite1
elif cond2:
suite2
"""
class ASTTestCase(unittest.TestCase):
def assertASTEqual(self, ast1, ast2):
self.assertEqual(ast.dump(ast1), ast.dump(ast2))
@ -159,6 +177,10 @@ def test_class_decorators(self):
def test_class_definition(self):
self.check_roundtrip("class A(metaclass=type, *[], **{}): pass")
def test_elifs(self):
self.check_roundtrip(elif1)
self.check_roundtrip(elif2)
class DirectoryTestCase(ASTTestCase):
"""Test roundtrip behaviour on all files in Lib and Lib/test."""