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_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_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_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_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_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_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_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 python_gut(path): with open(path) as module_file: output = gut.gut_module(module_file.read()) source_widget = _syntax_highlight_using_path(_fix_input(output), path) return Status.normal, source_widget
def test_commented_out_function(self): program = textwrap.dedent(""" # def bar(): # pass """) self.assertEqual(gut.gut_module(program), program)
def test_import(self): program = "import hello" self.assertEqual(gut.gut_module(program), program)