def check_positions_against_ast(self, snippet):
    code = compile(snippet, 'test_compile.py', 'exec')
    ast_tree = compile(snippet, 'test_compile.py', 'exec', _ast.PyCF_ONLY_AST)
    self.assertTrue((type(ast_tree) == _ast.Module))
    (lines, end_lines, columns, end_columns) = (set(), set(), set(), set())

    class SourceOffsetVisitor(ast.NodeVisitor):

        def generic_visit(self, node):
            super().generic_visit(node)
            if ((not isinstance(node, ast.expr)) and (not isinstance(node, ast.stmt))):
                return
            lines.add(node.lineno)
            end_lines.add(node.end_lineno)
            columns.add(node.col_offset)
            end_columns.add(node.end_col_offset)
    SourceOffsetVisitor().visit(ast_tree)
    for (line, end_line, col, end_col) in code.co_positions():
        if (line is not None):
            self.assertIn(line, lines)
        if (end_line is not None):
            self.assertIn(end_line, end_lines)
        if (col is not None):
            self.assertIn(col, columns)
        if (end_col is not None):
            self.assertIn(end_col, end_columns)
    return (code, ast_tree)
def check_positions_against_ast(self, snippet):
    code = compile(snippet, 'test_compile.py', 'exec')
    ast_tree = compile(snippet, 'test_compile.py', 'exec', _ast.PyCF_ONLY_AST)
    self.assertTrue((type(ast_tree) == _ast.Module))
    (lines, end_lines, columns, end_columns) = (set(), set(), set(), set())

    class SourceOffsetVisitor(ast.NodeVisitor):

        def generic_visit(self, node):
            super().generic_visit(node)
            if ((not isinstance(node, ast.expr)) and (not isinstance(node, ast.stmt))):
                return
            lines.add(node.lineno)
            end_lines.add(node.end_lineno)
            columns.add(node.col_offset)
            end_columns.add(node.end_col_offset)
    SourceOffsetVisitor().visit(ast_tree)
    for (line, end_line, col, end_col) in code.co_positions():
        if (line is not None):
            self.assertIn(line, lines)
        if (end_line is not None):
            self.assertIn(end_line, end_lines)
        if (col is not None):
            self.assertIn(col, columns)
        if (end_col is not None):
            self.assertIn(end_col, end_columns)
    return (code, ast_tree)