# Path: pycc/asttools/parse.py
# def parse(source, filename='<unknown>', mode='exec'):
#     """An ast.parse extension.
# 
#     This function behaves identically to the standard ast.parse except that it
#     adds parent and sibling references to each node.
#     """
#     node = ast.parse(source, filename, mode)
#     references.add_parent_references(node)
#     references.add_sibling_references(node)
# 
#     return node
# 
# Path: pycc/asttools/scope.py
# SCOPE_TYPE = enum.Enum(("MODULE", "FUNCTION", "CLASS"))
# def is_scope(node):
# def scope_type(node):
# def parent_scope(node):
# def child_scopes(node):


import pytest
from pycc.asttools import parse
from pycc.asttools import scope
@pytest.fixture
def func_node(node):
    """Get the function AST node from the source."""
    return node.body[0]


@pytest.fixture
def cls_node(node):
    """Get the class AST node from the source."""
    return node.body[1]


@pytest.fixture
def method_node(node):
    """Get the function AST of the class method."""
    return node.body[1].body[0]


def test_is_scope(node, func_node, cls_node, method_node):
    """Test that scopes are properly identified."""
    assert scope.is_scope(node) is True
    assert scope.is_scope(func_node) is True
    assert scope.is_scope(cls_node) is True
    assert scope.is_scope(method_node) is True


def test_scope_type(node, func_node, cls_node, method_node):
    """Test that scope types are property identified."""
    assert scope.scope_type(node) is scope.SCOPE_TYPE.MODULE
    assert scope.scope_type(func_node) is scope.SCOPE_TYPE.FUNCTION

# Path: pycc/asttools/parse.py
# def parse(source, filename='<unknown>', mode='exec'):
#     """An ast.parse extension.
# 
#     This function behaves identically to the standard ast.parse except that it
#     adds parent and sibling references to each node.
#     """
#     node = ast.parse(source, filename, mode)
#     references.add_parent_references(node)
#     references.add_sibling_references(node)
# 
#     return node
# 
# Path: pycc/asttools/scope.py
# SCOPE_TYPE = enum.Enum(("MODULE", "FUNCTION", "CLASS"))
# def is_scope(node):
# def scope_type(node):
# def parent_scope(node):
# def child_scopes(node):


# Path: tests/asttools/test_scope.py
import pytest
from pycc.asttools import parse
from pycc.asttools import scope

@pytest.fixture
def func_node(node):
    """Get the function AST node from the source."""
    return node.body[0]


@pytest.fixture
def cls_node(node):
    """Get the class AST node from the source."""
    return node.body[1]


@pytest.fixture
def method_node(node):
    """Get the function AST of the class method."""
    return node.body[1].body[0]


def test_is_scope(node, func_node, cls_node, method_node):
    """Test that scopes are properly identified."""
    assert scope.is_scope(node) is True
    assert scope.is_scope(func_node) is True
    assert scope.is_scope(cls_node) is True
    assert scope.is_scope(method_node) is True


def test_scope_type(node, func_node, cls_node, method_node):
    """Test that scope types are property identified."""
    assert scope.scope_type(node) is scope.SCOPE_TYPE.MODULE
    assert scope.scope_type(func_node) is scope.SCOPE_TYPE.FUNCTION

    assert scope.scope_type(cls_node) is scope.SCOPE_TYPE.CLASS