Hi all,
As I was fixing an issue in our API related to url encodings, I noticed a problem should have been caught by a test that was somehow passing. (Remember, make sure your test can fail!)
If you had some path /some/path/Spam%20Ham, and a URL pattern to capture /some/path/(?P<foo>.+)$, it's not unreasonable to think to think your named capture would pick up "Spam Ham" (with an actual space) and send that to your view. And indeed it does exactly that, when you make that request through the Django test client.
This is because there's an explicit call to unquote in django.test.client.RequestFactory before proceeding to build a WSGIRequest.
(The behavior of the development server is similar to the test client, although I haven't investigated for what exact reason.)
But when an actual WSGI server makes the same call, WSGIHandler doesn't make that same call to unquote; it passes the exact URL through to WSGIRequest. This leads to a scenario where, in the above example, views will see "Spam Ham" as the value of foo in unit tests, but will see "Spam%20Ham" when run in production.
This strikes me as bug worthy. I don't have particularly strong feelings on which is the correct behavior, but both behaviors should be the same.
I'd be willing to take on the patch once I get some input from others.
Thoughts?