Exemplo n.º 1
0
def test_ImportStatement_relative_local_1():
    stmt = ImportStatement("from .  import bar , bar2 as baz2")
    assert stmt.fromname == "."
    assert stmt.aliases == (("bar", None), ("bar2", "baz2"))
    assert stmt.imports == (Import(ImportSplit(".", "bar", None)),
                            Import(ImportSplit(".", "bar2", "baz2")))
    assert str(stmt) == "from . import bar, bar2 as baz2"
Exemplo n.º 2
0
def test_ImportStatement_alias_1():
    stmt = ImportStatement("from foo  import bar  as  bar,   bar as   baz")
    assert stmt.fromname == "foo"
    assert stmt.aliases == (("bar", "bar"), ("bar", "baz"))
    assert stmt.imports == (Import(ImportSplit("foo", "bar", "bar")),
                            Import(ImportSplit("foo", "bar", "baz")))
    assert str(stmt) == "from foo import bar as bar, bar as baz"
Exemplo n.º 3
0
def test_ImportStatement_multi_1():
    stmt = ImportStatement("from foo  import bar, bar2, bar")
    assert stmt.fromname == "foo"
    assert stmt.aliases == (("bar", None), ("bar2", None), ("bar", None))
    assert stmt.imports == (Import(ImportSplit("foo", "bar", None)),
                            Import(ImportSplit("foo", "bar2", None)),
                            Import(ImportSplit("foo", "bar", None)))
    assert str(stmt) == "from foo import bar, bar2, bar"
Exemplo n.º 4
0
def test_Import_import_as_same_1():
    imp = Import("import   foo . bar  as  bar")
    assert imp.fullname == "foo.bar"
    assert imp.import_as == "bar"
    assert imp.split == ImportSplit("foo", "bar", None)
    assert str(imp) == "from foo import bar"
    assert imp == Import("from foo import bar")
Exemplo n.º 5
0
def test_Import_from_Statement_1():
    imp = Import(ImportStatement("from foo import bar"))
    assert imp.fullname == "foo.bar"
    assert imp.import_as == "bar"
    assert imp.split == ImportSplit("foo", "bar", None)
    assert str(imp) == "from foo import bar"
    assert imp == Import("from foo import bar")
Exemplo n.º 6
0
def test_Import_module_1():
    imp = Import("import   foo . bar")
    assert imp.fullname == "foo.bar"
    assert imp.import_as == "foo.bar"
    assert imp.split == ImportSplit(None, "foo.bar", None)
    assert str(imp) == "import foo.bar"
Exemplo n.º 7
0
def test_Import_relative_local_1():
    imp = Import("from . import foo")
    assert imp.fullname == ".foo"
    assert imp.import_as == "foo"
    assert imp.split == ImportSplit(".", "foo", None)
    assert str(imp) == "from . import foo"
Exemplo n.º 8
0
def test_Import_relative_1():
    imp = Import("from .foo import bar")
    assert imp.fullname == ".foo.bar"
    assert imp.import_as == "bar"
    assert imp.split == ImportSplit(".foo", "bar", None)
    assert str(imp) == "from .foo import bar"
Exemplo n.º 9
0
def test_Import_basic_1():
    imp = Import("from foo.foof import bar")
    assert imp.fullname == "foo.foof.bar"
    assert imp.import_as == "bar"
    assert imp.split == ImportSplit("foo.foof", "bar", None)
    assert str(imp) == "from foo.foof import bar"
Exemplo n.º 10
0
def test_ImportStatement_relative_1():
    stmt = ImportStatement("from .foo import bar")
    assert stmt.fromname == ".foo"
    assert stmt.aliases == (("bar", None), )
    assert stmt.imports == (Import(ImportSplit(".foo", "bar", None)), )
    assert str(stmt) == "from .foo import bar"
Exemplo n.º 11
0
def test_ImportStatement_deep_member_1():
    stmt = ImportStatement("from foo.bar import baz")
    assert stmt.fromname == "foo.bar"
    assert stmt.aliases == (("baz", None), )
    assert stmt.imports == (Import(ImportSplit("foo.bar", "baz", None)), )
    assert str(stmt) == "from foo.bar import baz"
Exemplo n.º 12
0
def test_ImportStatement_1():
    stmt = ImportStatement("import  foo . bar")
    assert stmt.fromname == None
    assert stmt.aliases == (("foo.bar", None), )
    assert stmt.imports == (Import(ImportSplit(None, "foo.bar", None)), )
    assert str(stmt) == "import foo.bar"