-
-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow calls to requsts between calls to responses.add #375
Conversation
Codecov Report
@@ Coverage Diff @@
## master #375 +/- ##
==========================================
+ Coverage 96.51% 96.63% +0.11%
==========================================
Files 3 3
Lines 1319 1365 +46
==========================================
+ Hits 1273 1319 +46
Misses 46 46
Continue to review full report at Codecov.
|
@markstory Is this good to go? |
assert_response(resp, "best") | ||
|
||
run() | ||
assert_reset() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might be missing some coverage on multiple responses. These changes cause the following test to fail, while it current passes on master.
def test_multiple_responses_out_of_order_two():
@responses.activate
def run():
responses.add(responses.GET, "http://example.com", body="test")
responses.add(responses.GET, "http://example.com", body="rest")
responses.add(responses.GET, "http://example.com", body="fest")
responses.add(responses.GET, "http://example.com", body="best")
resp = requests.get("http://example.com")
assert_response(resp, "test")
resp = requests.get("http://example.com")
assert_response(resp, "rest")
resp = requests.get("http://example.com")
assert_response(resp, "fest")
resp = requests.get("http://example.com")
assert_response(resp, "best")
# After all responses are used, last response should be repeated
resp = requests.get("http://example.com")
assert_response(resp, "best")
run()
assert_reset()
Co-authored-by: Mark Story <[email protected]>
Co-authored-by: Mark Story <[email protected]>
@markstory |
This change allows the use of multiple responses intermixed by calls to requests by removing previous matches that have already been called if multiple exist.