Opened 12 years ago
Closed 12 years ago
#20275 closed Bug (duplicate)
WSGI environ variables not set for test client's login() request
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Testing framework | Version: | 1.5 |
Severity: | Normal | Keywords: | |
Cc: | bmispelon@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The fake HttpRequest
object created in the test client's login()
method does not contain any of the minimum set of WSGI environ variables defined in RequestFactory._base_environ
. This becomes an issue when you have a signal receiver listening to auth.signals.user_logged_in
and expecting a valid-looking request
object to exist.
The specific issue I've got is that REMOTE_ADDR
does not exist.
Is this a bug, or is there a reason I'm missing as to why this request object isn't valid.
Change History (3)
comment:1 by , 12 years ago
Cc: | added |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 12 years ago
Yup, that was what I was going to suggest if the request seemed reasonable. I just thought it was a bit hard to believe that this hadn't been an issue for anyone else before.
comment:3 by , 12 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Well it turns out this issue has been discovered before (sorry, I should have checked first): #15179.
I'm closing this one as a duplicate.
I'm not sure either if this is a bug or not but in any case, it looks like a reasonable request.
From a quick look, it seems like it wouldn't be too hard to achieve by changing this line: https://github.com/django/django/blob/master/django/test/client.py#L542 to something like
request = self.request()
.