def test_bc_l1_def_first_formatting(): tree = parse(bigcode) path = [0, "first_formatting"] assert path_to_bounding_box(tree, path) == ((1, 4), (1, 4)) path = [0, "first_formatting", 0] assert path_to_bounding_box(tree, path) == ((1, 4), (1, 4)) path = [0, "first_formatting", 0, "value"] check_path(bigcode, [(1, 4)], path)
def check_path(code, positions, target_path): tree = parse(code) for position in positions: path = position_to_path(tree, position) assert path == target_path if path is None: assert position_to_node(tree, position) is None return node = path_to_node(tree, path) assert isinstance(node, string_instance) assert position_to_node(tree, position) is node if target_path is not None: bounding_box = (positions[0], positions[-1]) assert path_to_bounding_box(tree, path) == bounding_box
def check_path(code, positions, target_path): tree = parse(code) for (line, column) in positions: path = position_to_path(tree, line, column) assert path == target_path if path is None: assert position_to_node(tree, line, column) is None return node = path_to_node(tree, path) assert isinstance(node, string_instance) assert position_to_node(tree, line, column) is node if target_path is not None: bounding_box = (positions[0], positions[-1]) assert path_to_bounding_box(tree, path) == bounding_box
def test_bc_l1_def_second_formatting(): path = [0, "second_formatting"] tree = parse(bigcode) assert path_to_bounding_box(tree, path) == ((1, 8), (1, 7))
def test_bb_comment(): node = parse("# comment")[0] assert path_to_bounding_box(node, None) == ((1, 1), (1, 9))
def test_bb_string(): node = parse("\"hello\"")[0] assert path_to_bounding_box(node, []) == ((1, 1), (1, 7))