Opened 15 years ago
Closed 14 years ago
#15898 closed Bug (fixed)
Add wsgi.input to RequestFactory's base environ
| Reported by: | Ricky Rosario | Owned by: | nobody |
|---|---|---|---|
| Component: | Testing framework | Version: | 1.3 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Design decision needed | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
wsgi.input is required but it is not provided in the base environ of RequestFactory. This causes an exception when creating a generic request:
>>> from django.test.client import RequestFactory
>>> RequestFactory().request()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/rlr/.virtualenvs/django/src/django/django/test/client.py", line 208, in request
return WSGIRequest(self._base_environ(**request))
File "/Users/rlr/.virtualenvs/django/src/django/django/core/handlers/wsgi.py", line 138, in __init__
if type(socket._fileobject) is type and isinstance(self.environ['wsgi.input'], socket._fileobject):
KeyError: 'wsgi.input'
Attachments (1)
Change History (4)
by , 15 years ago
| Attachment: | patch_wsgi_input_RequestFactory.diff added |
|---|
comment:1 by , 15 years ago
| Type: | Uncategorized → Bug |
|---|
comment:2 by , 15 years ago
| Triage Stage: | Unreviewed → Design decision needed |
|---|
Checked this out -- it is a real bug in 1.3, but it's a non-standard use of RequestFactory. That said, this patch (which I tested out) does seem to be useful in that it allows a basic request to be used without having to go through one of the other methods.
The real question is do you want request to be used like a public method. It's not documented, so if it's considered a private method this is a non-issue bug.
comment:3 by , 14 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
| UI/UX: | unset |
I fixed that at r16933.
Added wsgi.input to RequestFactory base environ, and added a test that verifies that RequestFactory().request() now works.