Coding style.
- Incorporate gut into tools. - Remove gut tests which were only useful for developing the old implementation.
This commit is contained in:
parent
d471934946
commit
2da603c5bf
3 changed files with 30 additions and 220 deletions
|
|
@ -1,163 +0,0 @@
|
|||
#!/usr/bin/env python3.8
|
||||
|
||||
|
||||
import textwrap
|
||||
import unittest
|
||||
|
||||
import eris.gut as gut
|
||||
|
||||
|
||||
class GutTestCase(unittest.TestCase):
|
||||
|
||||
def test_import(self):
|
||||
program = "import hello"
|
||||
self.assertEqual(gut.gut_module(program), program)
|
||||
|
||||
def test_import_and_function(self):
|
||||
program = textwrap.dedent("""
|
||||
import hello
|
||||
|
||||
def first():
|
||||
a = 1
|
||||
""")
|
||||
expected = textwrap.dedent("""
|
||||
import hello
|
||||
|
||||
def first():
|
||||
""")
|
||||
self.assertEqual(gut.gut_module(program), expected)
|
||||
|
||||
def test_import_and_function_and_command(self):
|
||||
program = textwrap.dedent("""
|
||||
import hello
|
||||
|
||||
def first():
|
||||
a = 1
|
||||
|
||||
b = 1
|
||||
""")
|
||||
expected = textwrap.dedent("""
|
||||
import hello
|
||||
|
||||
def first():
|
||||
|
||||
b = 1
|
||||
""")
|
||||
self.assertEqual(gut.gut_module(program), expected)
|
||||
|
||||
def test_import_and_class(self):
|
||||
program = textwrap.dedent("""
|
||||
import hello
|
||||
|
||||
class Foo:
|
||||
|
||||
def bar():
|
||||
a = 1
|
||||
""")
|
||||
expected = textwrap.dedent("""
|
||||
import hello
|
||||
|
||||
class Foo:
|
||||
|
||||
def bar():
|
||||
""")
|
||||
self.assertEqual(gut.gut_module(program), expected)
|
||||
|
||||
def test_short_blank_line_in_def(self):
|
||||
program = textwrap.dedent("""
|
||||
def bar():
|
||||
a = 1
|
||||
|
||||
b = 2
|
||||
""")
|
||||
expected = textwrap.dedent("""
|
||||
def bar():
|
||||
""")
|
||||
self.assertEqual(gut.gut_module(program), expected)
|
||||
|
||||
def test_nested_functions(self):
|
||||
program = textwrap.dedent("""
|
||||
def bar():
|
||||
a = 1
|
||||
def foo():
|
||||
pass
|
||||
b = 2
|
||||
""")
|
||||
expected = textwrap.dedent("""
|
||||
def bar():
|
||||
""")
|
||||
self.assertEqual(gut.gut_module(program), expected)
|
||||
|
||||
def test_multiline_signature(self):
|
||||
program = textwrap.dedent("""
|
||||
def bar(a, b,
|
||||
c, d):
|
||||
a = 1
|
||||
""")
|
||||
expected = textwrap.dedent("""
|
||||
def bar(a, b,
|
||||
c, d):
|
||||
""")
|
||||
self.assertEqual(gut.gut_module(program), expected)
|
||||
|
||||
def test_comment_in_signature_line(self):
|
||||
program = textwrap.dedent("""
|
||||
def bar(): # comment
|
||||
pass
|
||||
""")
|
||||
expected = textwrap.dedent("""
|
||||
def bar(): # comment
|
||||
""")
|
||||
self.assertEqual(gut.gut_module(program), expected)
|
||||
|
||||
def test_indented_comment_in_body(self):
|
||||
program = textwrap.dedent("""
|
||||
def bar():
|
||||
pass
|
||||
# comment
|
||||
pass
|
||||
""")
|
||||
expected = textwrap.dedent("""
|
||||
def bar():
|
||||
""")
|
||||
self.assertEqual(gut.gut_module(program), expected)
|
||||
|
||||
def test_non_indented_comment_in_body(self):
|
||||
program = textwrap.dedent("""
|
||||
def bar():
|
||||
pass
|
||||
# comment
|
||||
pass
|
||||
""")
|
||||
expected = textwrap.dedent("""
|
||||
def bar():
|
||||
""")
|
||||
self.assertEqual(gut.gut_module(program), expected)
|
||||
|
||||
def test_non_indented_comment_after_body(self):
|
||||
program = textwrap.dedent("""
|
||||
def bar():
|
||||
pass
|
||||
pass
|
||||
|
||||
# comment
|
||||
pass
|
||||
""")
|
||||
expected = textwrap.dedent("""
|
||||
def bar():
|
||||
|
||||
# comment
|
||||
pass
|
||||
""")
|
||||
self.assertEqual(gut.gut_module(program), expected)
|
||||
|
||||
def test_commented_out_function(self):
|
||||
program = textwrap.dedent("""
|
||||
# def bar():
|
||||
# pass
|
||||
""")
|
||||
self.assertEqual(gut.gut_module(program), program)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue