コード例 #1
0
ファイル: test_imports.py プロジェクト: zibuyu1995/mode
def test_load_extension_classes():
    with patch_iter_entry_points():
        with patch('mode.utils.imports.symbol_by_name') as sbn:
            assert list(load_extension_classes('foo')) == [
                EntrypointExtension('ep1', sbn.return_value),
                EntrypointExtension('ep2', sbn.return_value),
            ]

            sbn.assert_has_calls([call('foo:a'), call('bar:c')])
コード例 #2
0
def test_load_extension_classes():
    with patch_iter_entry_points():
        with patch("mode.utils.imports.symbol_by_name") as sbn:
            assert list(load_extension_classes("foo")) == [
                EntrypointExtension("ep1", sbn.return_value),
                EntrypointExtension("ep2", sbn.return_value),
            ]

            sbn.assert_has_calls([call("foo:a"), call("bar:c")])
コード例 #3
0
def _maybe_load_extension_classes(namespace: str = 'faust.codecs') -> None:
    if namespace not in _extensions_finalized:
        _extensions_finalized[namespace] = True
        codecs.update(
            {name: cls()
             for name, cls in load_extension_classes(namespace)})
コード例 #4
0
ファイル: test_imports.py プロジェクト: zibuyu1995/mode
def test_load_extension_classes_syntax_error():
    with patch_iter_entry_points():
        with patch('mode.utils.imports.symbol_by_name') as sbn:
            sbn.side_effect = SyntaxError()
            with pytest.warns(UserWarning):
                assert list(load_extension_classes('foo')) == []