Registry / testing / django-request-mock

django-request-mock

JSON →
library0.1.4pypypiunverified

A library to create Django request objects that mock real HTTP requests, useful for testing views and request-dependent code. Latest version 0.1.4 is in maintenance mode with minimal updates; no recent release activity.

pip install django-request-mock
INSTALL
IMPORT
SIG · DJANGO-REQUEST-MOC
D
django-request-mock
testingpythonv0.1.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RequestMock
from request_mock import RequestMock
from request_mock import RequestMock

Creates a simple GET request mock and passes it to a view.

import os from request_mock import RequestMock def test_my_view(): request = RequestMock( method='GET', path='/test/', META={'HTTP_HOST': 'example.com', 'SERVER_NAME': 'example.com'}, data={'key': 'value'} ) # Now use request in your view response = my_view(request) assert response.status_code == 200
Debug
Known issues
gotchaThe `META` dictionary must include both 'HTTP_HOST' and 'SERVER_NAME' or request.get_host() may fail.
fix
Always set META with both HTTP_HOST and SERVER_NAME to match real Django behavior.
affects: all
deprecatedLibrary is no longer actively maintained; may not work with Django 4.0+ due to missing WSGIRequest attributes (e.g., 'headers').
fix
Consider using Django's built-in RequestFactory or pytest-django for testing.
affects: >=0.1.4
gotchaThe `data` parameter does not automatically parse query strings for GET requests; you must set QUERY_STRING in META or use a custom parser.
fix
For GET requests with query params, set META['QUERY_STRING'] explicitly.
affects: all
Upgrade
Version history
0.1.4latest on PyPI · released Mar 8, 2014
Audit
Dependencies
djangorequiredCore requirement for request objects
Agent activity
18 hits · last 30 days
node
16
Amazon
1
Resources
django-request-mock — pip install django-request-mock · libregistry