You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inconsistent behaviour of assert_all_requests_are_fired between decorator and context manager #726
When a RequestsMock() is used as a context manager, assert_all_requests_are_fired is defaulted to True and an exception is raised at the end of the context block if a response is unused. However, using the @responses.activate decorator on a test function defaults assert_all_requests_are_fired to False leading to inconsistent behaviour.
Additional context
As a workaround, I have tried setting responses.mock.assert_all_requests_are_fired = True in conftest.py or just after an import of requests. However, this does not change the behaviour. The issue appears to be that the value in the default mock is never used as it gets defaulted by a default parameter in activate(), see: code.
Activity
markstory commentedon Jul 8, 2024
Changing the default values is not something we can easily do at this point in time as it will break existing assumptions in userland code.
Because of fixes we had to make to fix nested scopes, I don't think this is currently working. But it should be possible to have it work.
andrew-cybsafe commentedon Jul 16, 2024
@markstory I've opened PR #731 for this.