Ejemplo n.º 1
0
def test_find_external_from_import():
    modules = [Module("/", "foo/bar.py")]
    source = "from baz import bazz"
    finder = ReferenceFinder(modules, modules[0])
    finder.visit(ast.parse(source))
    assert finder.ext_references == set([
        Module("/", "baz.py"),
        Module("/", "baz/bazz.py")
    ])
Ejemplo n.º 2
0
def test_find_simple_from():
    modules = [Module("/", "foo/bar.py"), Module("/", "baz/__init__.py")]
    source = "from baz import Baz"
    finder = ReferenceFinder(modules, modules[0])
    finder.visit(ast.parse(source))
    assert finder.references == set([Module("/", "baz.py")])
Ejemplo n.º 3
0
def test_package_relative_from():
    modules = [Module("/", "foo/bar.py"), Module("/", "foo/baz.py")]
    source = "from . import bar"
    finder = ReferenceFinder(modules, modules[1])
    finder.visit(ast.parse(source))
    assert finder.references == set([Module("/", "foo/bar.py")])