예제 #1
0
 def test_search_body_parent_module(self):
     """Test whether the module is returned when searching for the parent of its child."""
     module_tree = astroid.parse("""
         f()
         """)
     node = module_tree.body[0]
     assert ASTUtil.search_body_parent(node) == module_tree
예제 #2
0
 def test_search_body_parent_function(self):
     """Test whether the function is returned when searching for the parent of its child."""
     module_tree = astroid.parse("""
         def f():
             return 0
         """)
     node = module_tree.body[0].body[0]
     assert ASTUtil.search_body_parent(node) == module_tree.body[0]