Skip to content

Requesting a URL, then changing the response will return the old response #212

@rbu

Description

@rbu

The documentation states:

You can also add multiple responses for the same url: ....

However, this is not true if you interleave adding and requesting responses:

>>> import responses
>>> import requests
>>> 
>>> responses.start()
>>> 
>>> responses.add(responses.GET, "https://example.com/",
...     json={'response': 'old'}
... )
>>> requests.get('https://example.com/').content
b'{"response": "old"}'
>>> 
>>> responses.add(responses.GET, "https://example.com/",
...     json={'response': 'new'}
... )
>>> 
>>> 
>>> requests.get('https://example.com/').content
b'{"response": "old"}'
>>> requests.get('https://example.com/').content
b'{"response": "new"}'
>>> requests.get('https://example.com/').content
b'{"response": "new"}'

Expected result: After adding the "new" response, a "new" response is returned in the subsequent request.

Requests version: '2.19.1', Python 3.6.6

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions