Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
    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)
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
 def test_commented_out_function(self):
     program = textwrap.dedent("""
         # def bar():
         #     pass
         """)
     self.assertEqual(gut.gut_module(program), program)
Ejemplo n.º 11
0
 def test_import(self):
     program = "import hello"
     self.assertEqual(gut.gut_module(program), program)