﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
23606	RequestFactory does not have a trace method.	Kévin Etienne	Rigel Di Scala	"When testing for views, `RequestFactory` is very useful to `get`, `post`, `put`, `patch`, `delete`, `head`, `options` a view.

However `trace` is missing from `RequestFactory` even if it's allowed by `django.views.generic.View`.

A simple fix would be to add `trace` to `RequestFactory`.

Example (taken from the doc):

{{{
rf = RequestFactory()
get_request = rf.get('/hello/')
post_request = rf.post('/submit/', {'foo': 'bar'})
}}}

I have one case where I'm extending `django.views.generic.View` and where I'm only allowing `dispatch`
to only use `get` and I've written a test to check this condition.

Example:

My view:
{{{#!python
from django.views.generics import View


class CustomView(View):
    http_method_names = ('get',)
}}}

My test:
{{{#!python
from django.test import RequestFactory, TestCase


class TestCustomView(TestCase):
    method_not_allowed = (
        'get', 
        'post',
        'put', 
        'patch', 
        'delete', 
        'head', 
        'options', 
        'trace',
    )

    def test_method_not_allowed(self):
        url = '/'
        for method in method_not_allowed:
            with self.subTest(method=method):
                request = getattr(RequestFactory(), method)(url)
                ...
                self.assert(status_code, 405)
}}}

The previous test when hit return the following error:
{{{#!bash
Traceback (most recent call last):
  File ""test_views.py"", line 85, in test_method_not_allowed
    request = getattr(RequestFactory(), method)(url)
AttributeError: 'RequestFactory' object has no attribute 'trace'
}}}"	New feature	closed	Testing framework	dev	Normal	fixed	test		Ready for checkin	1	0	0	0	0	0
