def test_sort_class_name(): local_package_names = ['hello'] import_names = [ ImportItem('.FooClass', 'hello.FooClass', 1, 0, True), ImportItem('.foo', 'hello.foo', 2, 0, True), ] sorted_ = sort_import_names(import_names, local_package_names) assert import_names == sorted_
def test_sort_class_name(): local_package_names = ['hello'] import_names = [ ImportItem('.FooClass', 'hello.FooClass', 1, 0, True), ImportItem('.foo', 'hello.foo', 2, 0, True), ] sorted_ = sort_import_names(import_names, local_package_names) assert import_names == sorted_
def test_sort_relative_import_belower(): local_package_names = ['hello'] import_names = [ ImportItem('hello.b', 'hello.b', 1, 0, False), ImportItem('.a', 'hello.a', 2, 0, True), ] sorted_ = sort_import_names(import_names, local_package_names) assert import_names == sorted_
def test_sort_relative_import_belower(): local_package_names = ['hello'] import_names = [ ImportItem('hello.b', 'hello.b', 1, 0, False), ImportItem('.a', 'hello.a', 2, 0, True), ] sorted_ = sort_import_names(import_names, local_package_names) assert import_names == sorted_
def test_sort_relative_import(): local_package_names = ['hello'] import_names = [ ('...aladin.Aladin', 'hello.aladin.Aladin', 1, 0, True), ('...book.Book', 'hello.book.Book', 2, 0, True), ('...yes24.Yes24', 'hello.yes24.Yes24', 3, 0, True), ('..db.sess', 'hello.web.db.sess', 4, 0, True), ('..util.get_count', 'hello.web.util.get_count', 5, 0, True), ('.form.BookForm', 'hello.web.admin.form.BookForm', 6, 0, True), ] sorted_ = sort_import_names(import_names, local_package_names) assert import_names == sorted_
def test_sort_all(): local_package_names = ['hello'] import_names = [ ImportItem('re.compile', 're.compile', 1, 0, False), ImportItem('pygments.highlight', 'pygments.highlight', 2, 0, False), ImportItem('.FOO', 'hello.FOO', 4, 0, True), ImportItem('.FooClass', 'hello.FooClass', 4, 0, True), ImportItem('.a', 'hello.a', 4, 0, True), ImportItem('.foo', 'hello.foo', 4, 0, True), ] sorted_ = sort_import_names(import_names, local_package_names) assert import_names == sorted_
def test_sort_relative_import(): local_package_names = ['hello'] import_names = [ ('...aladin.Aladin', 'hello.aladin.Aladin', 1, 0, True), ('...book.Book', 'hello.book.Book', 2, 0, True), ('...yes24.Yes24', 'hello.yes24.Yes24', 3, 0, True), ('..db.sess', 'hello.web.db.sess', 4, 0, True), ('..util.get_count', 'hello.web.util.get_count', 5, 0, True), ('.form.BookForm', 'hello.web.admin.form.BookForm', 6, 0, True), ] sorted_ = sort_import_names(import_names, local_package_names) assert import_names == sorted_
def test_sort_all(): local_package_names = ['hello'] import_names = [ ImportItem('re.compile', 're.compile', 1, 0, False), ImportItem('pygments.highlight', 'pygments.highlight', 2, 0, False), ImportItem('.FOO', 'hello.FOO', 4, 0, True), ImportItem('.FooClass', 'hello.FooClass', 4, 0, True), ImportItem('.a', 'hello.a', 4, 0, True), ImportItem('.foo', 'hello.foo', 4, 0, True), ] sorted_ = sort_import_names(import_names, local_package_names) assert import_names == sorted_
def test_sort_distinguish(): local_package_names = ['hello'] import_names = [ ('re.compile', 1, 0, False), ('pytest', 2, 0, False), ('pygments.highlight', 2, 0, True), ('hello.FOO', 3, 0, False), ('hello.foo', 3, 0, False), ('.FooClass', 4, 0, True), ('.a', 4, 0, True), ] sorted_ = sort_import_names(import_names, local_package_names, True) assert import_names == sorted_
def test_sort_constant(): local_package_names = ['hello'] import_names = [('.FOO', 1, 0, True), ('.foo', 2, 0, True)] sorted_ = sort_import_names(import_names, local_package_names) assert import_names == sorted_