Skip to content
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

Fixed the issue when reset() method was called in not stopped mock #516

Merged
merged 3 commits into from Mar 17, 2022

Conversation

beliaev-maksim
Copy link
Collaborator

@beliaev-maksim beliaev-maksim commented Mar 16, 2022

closes #511

Fix the issue - one line of code, know where to fix the issue - 1.5h :D

explanation:
when reset in the middle, we clean up _patcher which is a req for another issue. But when we do it, it prevents patcher to be stopped.
In PR test case actual mock is applied from rsps2 instead of responses.mock because we did not clean up patcher on exit from the context manager

@codecov
Copy link

codecov bot commented Mar 16, 2022

Codecov Report

Merging #516 (42415ef) into master (1724937) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #516   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines         2305      2315   +10     
=========================================
+ Hits          2305      2315   +10     
Impacted Files Coverage Δ
responses/__init__.py 100.00% <100.00%> (ø)
responses/tests/test_responses.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1724937...42415ef. Read the comment docs.

with responses.RequestsMock() as rsps2:
rsps2.reset()
responses.add(responses.GET, "https://example.invalid", status=200)
print(requests.request("GET", "https://example.invalid"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be an assertion?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markstory
confirm that

@markstory markstory merged commit d0c9b7c into getsentry:master Mar 17, 2022
@beliaev-maksim beliaev-maksim deleted the mbeliaev/fix_511 branch March 17, 2022 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Responses 0.19.0 seems to break some s3 mocks
4 participants