getsentry / responses

A utility for mocking out the Python Requests library.
Apache License 2.0
4.08k stars 347 forks source link

Set repeat count for response #695

Closed efojs closed 7 months ago

efojs commented 7 months ago

Learned the hard way that responses repeat last added response, if it matches request. But I'd like it to "play" response only once. E.g. by setting repeat=0. So that it fails when cannot find matching not used response.

The use case? — Want to cover all requests sent in the test with precision.

May call_count help? — I don't think so, call_count is somewhat opposite. It checks the result, but I want to prevent it from happening. call_count will not tell me which requests are not handled.

Maybe it's already implemented and I'm just missing it?

Or what do you think about it? Is it an opportunity to contribute?

beliaev-maksim commented 7 months ago

Hello,

You probably talking about registry. Please read readme to see how to switch it.

You can always extend registry with custom one

efojs commented 7 months ago

Hello! Yes, OrderedRegistry does the trick. Missed that. Thank you very much!