Example fails due to "AttributeError: 'dict' object has no attribute 'should'"
krichter722 opened this issue · 1 comments
krichter722 commented
The example in README.md
import httpretty
import requests
@httpretty.activate
def test_httpbin():
httpretty.register_uri(
httpretty.GET,
"https://httpbin.org/ip",
body='{"origin": "127.0.0.1"}'
)
response = requests.get('https://httpbin.org/ip')
response.json().should.equal({'origin': '127.0.0.1'})
httpretty.latest_requests().should.have.length_of(1)
httpretty.last_request().should.equal(httpretty.latest_requests()[0])
httpretty.last_request().body.should.equal('{"origin": "127.0.0.1"}')
fails due to
Traceback (most recent call last):
File "/mnt/mock_server.py", line 24, in <module>
test_httpbin()
File "/usr/local/lib/python3.7/site-packages/httpretty/core.py", line 1864, in wrapper
return test(*args, **kw)
File "/mnt/mock_server.py", line 16, in test_httpbin
response.json().should.equal({'origin': '127.0.0.1'})
AttributeError: 'dict' object has no attribute 'should'
with Python 3.7 (requires installation of requests with pip), 3.8 and 3.9.
krichter722 commented
I was missing the sure
import which overloads requests
and make the example work, sorry for the noise.