# Path: tests/helpers.py
# def pytest_funcarg__project(request):
#     for crap_module in ('toimport', 'package'):
#         if crap_module in sys.modules:
#             del sys.modules[crap_module]
# 
#     p = Project('.')
#     p.create_module = create_module.__get__(p, Project)
#     p.create_scope = create_scope.__get__(p, Project)
#     p.set_root = set_project_root.__get__(p, Project)
#     return p
# 
# def do_docstring(project, source, filename=None):
#     filename = filename or 'test.py'
#     source, pos = get_source_and_pos(source)
#     return get_docstring(project, source, pos, filename)
# 
# def do_assist(project, source, filename=None):
#     filename = filename or 'test.py'
#     source, pos = get_source_and_pos(source)
#     return assist(project, source, pos, filename)[1]


from .helpers import pytest_funcarg__project, do_docstring, do_assist

def test_re_compile_must_return_good_object(project):
    project.register_hook('supplement.hooks.override')
    result = do_assist(project, '''
        import re

        re.compile('match').|
    ''')

    assert 'groups' in result
    assert 'findall' in result

def test_builtin_override(project):
    project.register_hook('supplement.hooks.override')

# Path: tests/helpers.py
# def pytest_funcarg__project(request):
#     for crap_module in ('toimport', 'package'):
#         if crap_module in sys.modules:
#             del sys.modules[crap_module]
# 
#     p = Project('.')
#     p.create_module = create_module.__get__(p, Project)
#     p.create_scope = create_scope.__get__(p, Project)
#     p.set_root = set_project_root.__get__(p, Project)
#     return p
# 
# def do_docstring(project, source, filename=None):
#     filename = filename or 'test.py'
#     source, pos = get_source_and_pos(source)
#     return get_docstring(project, source, pos, filename)
# 
# def do_assist(project, source, filename=None):
#     filename = filename or 'test.py'
#     source, pos = get_source_and_pos(source)
#     return assist(project, source, pos, filename)[1]


# Path: tests/test_override.py
from .helpers import pytest_funcarg__project, do_docstring, do_assist


def test_re_compile_must_return_good_object(project):
    project.register_hook('supplement.hooks.override')
    result = do_assist(project, '''
        import re

        re.compile('match').|
    ''')

    assert 'groups' in result
    assert 'findall' in result

def test_builtin_override(project):
    project.register_hook('supplement.hooks.override')

    result = do_assist(project, '''