Closed janrito closed 1 year ago
I've never introduced functions and regexes because I consider both bad practices. I don't like the idea of having dynamic tests, and I'd rather use something like pytest parametrize, but I am open to discuss it further.
Yes, that sentence is the reason I've asked the question. I don't know of another way of achieving what I need without functions. I was hoping that there was a different method, that I just hadn't found it yet.
You probably need something like:
from mocket.mockhttp import Entry, Response
responses = [Response(status=302, match_querystring=False)] * MAX_REDIRECTS + [Response(match_querystring=False)]
Entry.register(Entry.GET, test_url, *responses)
While for the test using delayed
you could have Mocket raising an exception for you instead. See here.
You probably need something like:
from mocket.mockhttp import Entry, Response responses = [Response(status=302, match_querystring=False)] * MAX_REDIRECTS + [Response(match_querystring=False)] Entry.register(Entry.GET, test_url, *responses)
Oh this is great. I hadn't thought of multiple Response objects.
While for the test using delayed you could have Mocket raising an exception for you instead. See here.
I see. I’m not sure why this feels less like what we wanted to test, but it might be good enough. I will give it a try
We are using httpretty's response body from functions and regexed url matching in order to test timeouts and redirects. I'm not suggesting this is the right way, but haven't figured out how to replicate these using mocket.