Skip to content

Commit

Permalink
use response.content
Browse files Browse the repository at this point in the history
  • Loading branch information
gugek authored and mloesch committed Apr 8, 2018
1 parent 02ff341 commit bac01ac
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sickle/response.py
Expand Up @@ -34,7 +34,7 @@ def raw(self):
@property
def xml(self):
"""The server's response as parsed XML."""
return etree.XML(self.http_response.text.encode("utf8"),
return etree.XML(self.http_response.content,
parser=XMLParser)

def __repr__(self):
Expand Down
1 change: 1 addition & 0 deletions sickle/tests/test_harvesting.py
Expand Up @@ -30,6 +30,7 @@ def __init__(self, text):
# request's response object carry an attribute 'text' which contains
# the server's response data encoded as unicode.
self.text = text
self.content = text.encode('utf-8')


def mock_harvest(*args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions sickle/tests/test_sickle.py
Expand Up @@ -29,7 +29,7 @@ def test_invalid_iterator(self):
Sickle("http://localhost", iterator=None)

def test_pass_request_args(self):
mock_response = Mock(text='<xml/>')
mock_response = Mock(text=u'<xml/>', content='<xml/>')
mock_get = Mock(return_value=mock_response)
with patch('sickle.app.requests.get', mock_get):
sickle = Sickle('url', timeout=10, proxies=dict(),
Expand All @@ -41,7 +41,7 @@ def test_pass_request_args(self):
auth=('user', 'password'))

def test_override_encoding(self):
mock_response = Mock(text='<xml/>')
mock_response = Mock(text='<xml/>', content='<xml/>')
mock_get = Mock(return_value=mock_response)
with patch('sickle.app.requests.get', mock_get):
sickle = Sickle('url', encoding='encoding')
Expand Down

0 comments on commit bac01ac

Please sign in to comment.