예제 #1
0
def test_no_warning_for_clashed_uris(mock_warnings):
    _warn_if_uri_clash_on_same_marshaled_representation(
        uri_schema_mappings={},
        marshal_uri=functools.partial(
            _marshal_uri,
            origin_uri=None,
        ),
    )
    assert not mock_warnings.called
예제 #2
0
def test_warning_for_clashed_uris(mock_warnings):
    clashing_uris = ['path1', 'path2']
    marshaled_uri = 'SameString'

    _warn_if_uri_clash_on_same_marshaled_representation(
        uri_schema_mappings={
            urlparse(uri): mock.Mock()
            for uri in clashing_uris
        },
        marshal_uri=functools.partial(
            lambda *args, **kwargs: marshaled_uri,
            origin_uri=None,
        ),
    )

    mock_warnings.warn.assert_called_once_with(
        message='{} clashed to {}'.format(', '.join(sorted(clashing_uris)),
                                          marshaled_uri),
        category=Warning,
    )