示例#1
0
def test_ImportSet_without_imports_from_1():
    importset = ImportSet(
        ["from m1 import a, b", "from m2 import b, c", "from m3 import b, x"])
    result = importset.without_imports("from m1 import b; from m2 import b")
    expected = ImportSet(
        ["from m1 import a", "from m2 import c", "from m3 import b, x"])
    assert result == expected
示例#2
0
def test_ImportSet_without_imports_star_dot_1():
    importset = ImportSet("""
        import m94165726
        from   m68073152   import f59136817
        from   .m69396491  import f87639367
        from   .           import m81881832
        from   m97513719.a import f42218372
    """)
    result = importset.without_imports("from . import *")
    expected = ImportSet("""
        import m94165726
        from   m68073152   import f59136817
        from   m97513719.a import f42218372
    """)
    assert result == expected
示例#3
0
def test_ImportSet_without_imports_star_1():
    importset = ImportSet("""
        from m11321086.a   import f27811501, f04141733
        from m28630179.a   import f75932565, f54328537
        from m28630179.a.b import f46586889, f53411856
        from m28630179.x   import f10642186, f95537624
        from .m28630179.a  import f38714787, f42847225
    """)
    result = importset.without_imports("from m28630179.a import *")
    expected = ImportSet("""
        from m11321086.a   import f27811501, f04141733
        from m28630179.x   import f10642186, f95537624
        from .m28630179.a  import f38714787, f42847225
    """)
    assert result == expected
示例#4
0
def test_ImportSet_without_imports_exact_2():
    importset = ImportSet(
        ["from m1 import a", "import m1.a", "from m1.a import *"])
    result = importset.without_imports("import m1.a")
    expected = ImportSet("from m1 import a; from m1.a import *")
    assert result == expected
示例#5
0
def test_ImportSet_without_imports_no_action_1():
    importset = ImportSet("import a, b, c, d")
    result = importset.without_imports("import x, y")
    assert result is importset
示例#6
0
def test_ImportSet_without_imports_1():
    importset = ImportSet("import a, b, c, d")
    result = importset.without_imports("import x, d, b, y")
    expected = ImportSet("import a, c")
    assert result == expected