Skip to content

Commit 828b57f

Browse files
committed
Fix to_unicode to work for DRF hyperlink fields
1 parent 0d75821 commit 828b57f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

abe/unittest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def assert_matches_sample(self, path, label, url, response):
106106
:param url:
107107
The actual URL we want to compare with the sample
108108
:param response:
109-
The actual API response we want to match with the sample
109+
The actual API response we want to match with the sample.
110+
It is assumed to be a Django Rest Framework response object
110111
"""
111112
sample = self.load_sample(path)
112113
sample_request = sample.examples[label].request
@@ -115,4 +116,5 @@ def assert_matches_sample(self, path, label, url, response):
115116
self.assertEqual(url, sample_request.url)
116117
self.assertEqual(response.status_code, sample_response.status)
117118
if 'body' in sample_response:
118-
self.assert_data_equal(response.data, sample_response.body)
119+
response_parsed = response.data
120+
self.assert_data_equal(response_parsed, sample_response.body)

abe/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from datetime import datetime
2-
import decimal
32
import sys
43

54
_PY3 = sys.version_info >= (3, 0)
@@ -20,7 +19,7 @@ def to_unicode(data):
2019
"""
2120
if isinstance(data, datetime):
2221
data = datetime_to_string(data)
23-
elif isinstance(data, decimal.Decimal):
22+
else:
2423
data = str(data)
2524

2625
if not _PY3:

0 commit comments

Comments
 (0)