tools: Make python_gut more correct.
- Using the ast module to correctly determine the line numbers of the function bodies. - Should have done it this way in the beginning, but didn't know about ast module tracking line numbers. - No more heuristics. - Copes with different size indentations.
This commit is contained in:
parent
c8638c1bbe
commit
d471934946
2 changed files with 25 additions and 60 deletions
|
|
@ -90,27 +90,16 @@ class GutTestCase(unittest.TestCase):
|
|||
|
||||
def test_multiline_signature(self):
|
||||
program = textwrap.dedent("""
|
||||
def bar(a, b
|
||||
def bar(a, b,
|
||||
c, d):
|
||||
a = 1
|
||||
""")
|
||||
expected = textwrap.dedent("""
|
||||
def bar(a, b
|
||||
def bar(a, b,
|
||||
c, d):
|
||||
""")
|
||||
self.assertEqual(gut.gut_module(program), expected)
|
||||
|
||||
def test_tab_in_indentation(self):
|
||||
program = textwrap.dedent("""
|
||||
def bar():
|
||||
a = 1
|
||||
\tb=2
|
||||
""")
|
||||
expected = textwrap.dedent("""
|
||||
def bar():
|
||||
""")
|
||||
self.assertEqual(gut.gut_module(program), expected)
|
||||
|
||||
def test_comment_in_signature_line(self):
|
||||
program = textwrap.dedent("""
|
||||
def bar(): # comment
|
||||
|
|
@ -142,9 +131,6 @@ class GutTestCase(unittest.TestCase):
|
|||
""")
|
||||
expected = textwrap.dedent("""
|
||||
def bar():
|
||||
|
||||
# comment
|
||||
pass
|
||||
""")
|
||||
self.assertEqual(gut.gut_module(program), expected)
|
||||
|
||||
|
|
@ -153,6 +139,7 @@ class GutTestCase(unittest.TestCase):
|
|||
def bar():
|
||||
pass
|
||||
pass
|
||||
|
||||
# comment
|
||||
pass
|
||||
""")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue