Example #1
0
def test_select_url_custom_format():
    key = "not_available"
    urls = {}

    def format(key):
        return f"custom format for '{key}'"

    expected = format(key)

    with pytest.raises(RuntimeError) as exc_info:
        enc.select_url(urls, key, format=format)

        actual = exc_info.value.args[0]
        assert actual.endswith(expected)
Example #2
0
 def state_dict_url(self, framework: str) -> str:
     return enc.select_url(multi_layer_encoder_urls, framework)
Example #3
0
def test_select_url_not_available():
    key = "not_available"
    urls = {}

    with pytest.raises(RuntimeError):
        enc.select_url(urls, key)
Example #4
0
def test_select_url():
    key = "available"
    url = "https://pystiche.org"

    assert enc.select_url({key: url}, key) == url