Ejemplo n.º 1
0
 def test_periods_come_before_underscores(self):
     imports = [make_import('a.b'), make_import('a_b')]
     expect(AlphabetizesImports.alphabetize(imports)) == [make_import('a.b'),
                                                          make_import('a_b')]
Ejemplo n.º 2
0
 def test_uppercase_comes_before_lowercase(self):
     imports = [make_import('b'), make_import('a'), make_import('C')]
     expect(AlphabetizesImports.alphabetize(imports)) == [make_import('C'),
                                                          make_import('a'),
                                                          make_import('b')]
Ejemplo n.º 3
0
 def test_periods_come_before_after_letters(self):
     imports = [make_import('ab'), make_import('a.c'), make_import('a.b')]
     expect(AlphabetizesImports.alphabetize(imports)) == [make_import('a.b'),
                                                          make_import('a.c'),
                                                          make_import('ab')]
Ejemplo n.º 4
0
 def test_writes_imports_with_as_names(self):
     imports = [make_import('module', asname='asmodule'),
                make_import('module', 'name', 'asname')]
     expected = ('import module as asmodule\n'
                 'from module import name as asname')
     expect(WritesImports.write(imports)) == expected
Ejemplo n.º 5
0
 def test_writes_imports(self):
     imports = [make_import('b'), make_import('a', 'name')]
     expect(WritesImports.write(imports)) == 'import b\nfrom a import name'
Ejemplo n.º 6
0
 def test_extracts_from_as_imports(self):
     imports = ExtractsImports.extract('from mod import name as other_name')
     expect(imports) == [make_import('mod', 'name', 'other_name')]
Ejemplo n.º 7
0
 def test_extracts_module_as_imports(self):
     imports = ExtractsImports.extract('import name as other_name')
     expect(imports) == [make_import('name', None, 'other_name')]
Ejemplo n.º 8
0
 def test_finds_imports(self):
     imports = ExtractsImports.extract('import name\n'
                                       'from module import name')
     expect(imports) == [make_import('name', None),
                         make_import('module', 'name')]