-
-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Response count not reset when defining Response outside of test function #687
Comments
I would say that is the desired behavior you do not need to copy the object, you can set up test class and on teardown or setup of the method initialize the response or reset call count |
Do you mean by doing something like this?
|
that is a fixture which technically will work, but I would rather use https://docs.pytest.org/en/7.1.x/how-to/xunit_setup.html#method-and-function-level-setup-teardown |
Got it. But my main question was, the only way to reset the call count would be to set the |
or on every test you initialize a new object class Test:
def setup_method(self):
self.response_200_ok = responses.Response("GET", url)
def test1(self):
r = responses.add(self.response_200_ok ) smth like this |
But my goal is to reuse the same responses in multiple tests. That's why I started with:
|
then just reset the call counter. |
I prefer to define responses in a separate module outside of test functions.
But then the response.call_count is not reset when the test ends.
Adding copy.copy does fix the issue, but maybe this can be circumvented so I don't have to use that?
Example:
Working example:
The text was updated successfully, but these errors were encountered: