Skip to content

Commit

Permalink
attempt to reproduce #425
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielfalcao committed May 20, 2021
1 parent 0b74a86 commit 03b74fb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
3 changes: 1 addition & 2 deletions httpretty/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1614,8 +1614,7 @@ def historify_request(cls, headers, body='', sock=None):
if request not in cls.latest_requests:
cls.latest_requests.append(request)
else:
pos = cls.latest_requests.index(request)
cls.latest_requests[pos] = request
cls.latest_requests[-1] = request

logger.info("captured: {}".format(request))
return request
Expand Down
29 changes: 29 additions & 0 deletions tests/bugfixes/nosetests/test_425_latest_requests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import requests
import httpretty
from httpretty.errors import UnmockedError

from unittest import skip
from sure import expect


@httpretty.activate(allow_net_connect=True)
def test_latest_requests():
"#425 - httpretty.latest_requests() can be called multiple times"
httpretty.register_uri(httpretty.GET, 'http://google.com/', body="Not Google")
httpretty.register_uri(httpretty.GET, 'https://google.com/', body="Not Google")

requests.get('http://google.com/')
httpretty.latest_requests()[-1].url.should.equal('http://google.com/')
requests.get('https://google.com/')
httpretty.latest_requests()[-1].url.should.equal('https://google.com/')

httpretty.latest_requests().should.have.length_of(2)
httpretty.latest_requests()[-1].url.should.equal('https://google.com/')

requests.get('https://google.com/')
httpretty.latest_requests().should.have.length_of(3)
httpretty.latest_requests()[-1].url.should.equal('https://google.com/')

requests.get('http://google.com/')
httpretty.latest_requests().should.have.length_of(4)
httpretty.latest_requests()[-1].url.should.equal('http://google.com/')

0 comments on commit 03b74fb

Please sign in to comment.