Suggestion: Adding `params` to TestClient HTTP methods

It could! I usually use urlencode to put dynamic parameters in the URL:

resp = self.client.post("/widget/" + urlencode({"user": user.id}))

But this is hard to remember, and can lead to random failures if testing with random data that sometimes needs escaping.

Having a parameter for URL parameters would be neat. I’d suggest we use the name query_params, rather than just params, as per the ongoing Google Summer of Code project that will rename request.GET to request.query_params ( [GSOC 2023] Add Configurable Content Type Parsing and Modernise Request Object ).

2 Likes