Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2e1d453

Browse files
committed
Revert "Errors should be more explicit. Closes Yelp#44."
1 parent 64bffb4 commit 2e1d453

File tree

2 files changed

+0
-62
lines changed

2 files changed

+0
-62
lines changed

tests/errors_test.py

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import six
77

88
from tests.testing import resource_filename
9-
from yelp import errors
109
from yelp.errors import ErrorHandler
1110
from yelp.errors import InvalidParameter
1211

@@ -40,56 +39,3 @@ def test_error_handler_raises_correct_yelp_error(self):
4039
with pytest.raises(InvalidParameter) as err:
4140
self.handler.raise_error(error)
4241
assert "radius_filter" in err.value.text
43-
44-
45-
def _verify_error_message(error_cls):
46-
code = 400
47-
msg = 'Bad Request'
48-
resp = {
49-
'error': {
50-
'text': 'One or more parameters are invalid in request',
51-
'id': 'INVALID_PARAMETER',
52-
'field': 'term'
53-
}
54-
}
55-
err = error_cls(code, msg, resp)
56-
message = str(err)
57-
assert str(code) in message
58-
assert msg in message
59-
assert resp['error']['text'] in message
60-
return message
61-
62-
63-
def test_yelp_error():
64-
"""Error messages should contain the useful elements of the
65-
error response.
66-
"""
67-
message = _verify_error_message(errors.YelpError)
68-
# Pinning down something we don't currently include, though we could.
69-
assert 'term' not in message
70-
71-
72-
def test_invalid_parameter():
73-
"""InvalidParameter should also list the offending field."""
74-
message = _verify_error_message(errors.InvalidParameter)
75-
assert 'term' in message
76-
77-
78-
def test_error_message_handles_unicode():
79-
"""We should at least print recognizable forms of the errors.
80-
The less mangling we do the better, but some repr() might make sense.
81-
"""
82-
code = 400
83-
msg = u'Bäd'
84-
resp = {
85-
'error': {
86-
'text': u'Wröng',
87-
'id': u'ERRØR',
88-
'field': u'tërm'
89-
}
90-
}
91-
err = errors.YelpError(code, msg, resp)
92-
message = str(err)
93-
assert str(code) in message
94-
assert repr(msg) in message
95-
assert repr(resp['error']['text']) in message

yelp/errors.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ def __init__(self, code, msg, response):
1111
self.id = response['error']['id']
1212
self.text = response['error']['text']
1313

14-
def __str__(self):
15-
return repr({
16-
'code': self.code,
17-
'msg': self.msg,
18-
'id': self.id,
19-
'text': self.text,
20-
})
21-
2214

2315
class AreaTooLarge(YelpError):
2416
pass

0 commit comments

Comments
 (0)