示例#1
0
def test_imports_partial_file(index):
    src = dedent('''
        import re
        import sys


        a = "

        print(
        ''')
    imports = Imports(index, src)
    assert imports.update_source() == src
示例#2
0
def test_get_style_from_config(index, tmpdir):
    conf_file = tmpdir.join(PROJECT_CONFIG_FILE)
    conf_file.write(
        dedent('''
        [importmagic]
        multiline = parentheses_test
        max_columns = 42
        indent_with_tabs = 1
    '''))
    src = dedent('''
        from injector import Binder, Injector, InstanceProvider, Key, MappingKey, Module, Scope, ScopeDecorator, SequenceKey, inject, provides, singleton
        from waffle import stuff

        Binder, Injector, InstanceProvider, Key, MappingKey, Module, Scope, ScopeDecorator, SequenceKey, inject, provides, singleton, stuff
        ''').strip()

    imports = Imports(index, src, root_dir=tmpdir.strpath)
    imports.get_style_from_config()
    assert Imports._style == {
        'multiline': 'parentheses_test',
        'max_columns': 42,
        'indent_with_tabs': True,
    }