Exemplo n.º 1
0
def test_smart_import():
    assert smart_import('os') is os
    assert smart_import('sys:version_info') is sys.version_info
    assert smart_import('sys.version_info')

    with pytest.raises(AttributeError):
        smart_import('sys:foobarbazbazasdqwewqrewqfadf')
Exemplo n.º 2
0
Arquivo: base.py Projeto: melor/faust
 def _load_settings_from_source(self, source: Any, *,
                                silent: bool = False) -> Mapping:
     if isinstance(source, str):
         try:
             source = smart_import(source, imp=import_from_cwd)
         except (AttributeError, ImportError):
             if not silent:
                 raise
             return {}
     return force_mapping(source)