Opened 13 years ago

Closed 12 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)

patch_wsgi_input_RequestFactory.diff (2.4 KB ) - added by Ricky Rosario 13 years ago.
Added wsgi.input to RequestFactory base environ, and added a test that verifies that RequestFactory().request() now works.

Download all attachments as: .zip

Change History (4)

by Ricky Rosario, 13 years ago

Added wsgi.input to RequestFactory base environ, and added a test that verifies that RequestFactory().request() now works.

comment:1 by Ricky Rosario, 13 years ago

Type: UncategorizedBug

comment:2 by Travis Swicegood, 13 years ago

Triage Stage: UnreviewedDesign 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 Aymeric Augustin, 12 years ago

Resolution: fixed
Status: newclosed
UI/UX: unset

I fixed that at r16933.

Note: See TracTickets for help on using tickets.
Back to Top