Code

Opened 3 years ago

Closed 2 years ago

#15898 closed Bug (fixed)

Add wsgi.input to RequestFactory's base environ

Reported by: r1cky 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 r1cky 3 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)

Changed 3 years ago by r1cky

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

comment:1 Changed 3 years ago by r1cky

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Type changed from Uncategorized to Bug

comment:2 Changed 3 years ago by tswicegood

  • Triage Stage changed from Unreviewed to 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 Changed 2 years ago by aaugustin

  • Resolution set to fixed
  • Status changed from new to closed
  • UI/UX unset

I fixed that at r16933.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.