Don't encode strings as 'utf-8' twice in _get_cache_key. Closes #109.
This commit is contained in:
parent
387220c1d6
commit
c2b03afe55
|
@ -1070,7 +1070,7 @@ class _Request(object):
|
|||
|
||||
for key in keys:
|
||||
if key != "api_sig" and key != "api_key" and key != "sk":
|
||||
cache_key += key + _string(self.params[key])
|
||||
cache_key += key + self.params[key]
|
||||
|
||||
return hashlib.sha1(cache_key.encode("utf-8")).hexdigest()
|
||||
|
||||
|
|
17
tests/request_test.py
Normal file
17
tests/request_test.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import mock
|
||||
import pytest
|
||||
|
||||
import pylast
|
||||
|
||||
|
||||
def mock_network():
|
||||
return mock.Mock(
|
||||
_get_ws_auth=mock.Mock(return_value=("", "", ""))
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize('unicode_artist', [u'\xe9lafdasfdsafdsa', u'éééééééé'])
|
||||
def test_get_cache_key(unicode_artist):
|
||||
request = pylast._Request(mock_network(), 'some_method',
|
||||
params={'artist': unicode_artist})
|
||||
request._get_cache_key()
|
Loading…
Reference in a new issue