mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
Remove support for doctests
This commit is contained in:
parent
aeeb68f68a
commit
84f7758039
|
@ -5,13 +5,13 @@ Django REST framework also provides HTML and PlainText renderers that help self-
|
|||
by serializing the output along with documentation regarding the View, output status and headers,
|
||||
and providing forms and links depending on the allowed methods, renderers and parsers on the View.
|
||||
"""
|
||||
import copy
|
||||
import string
|
||||
from django import forms
|
||||
from django.template import RequestContext, loader
|
||||
from django.utils import simplejson as json
|
||||
from rest_framework.compat import yaml
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.request import clone_request
|
||||
from rest_framework.utils import dict2xml
|
||||
from rest_framework.utils import encoders
|
||||
from rest_framework.utils.breadcrumbs import get_breadcrumbs
|
||||
|
@ -227,12 +227,9 @@ class DocumentingHTMLRenderer(BaseRenderer):
|
|||
if not api_settings.FORM_METHOD_OVERRIDE:
|
||||
return # Cannot use form overloading
|
||||
|
||||
temp = request._method
|
||||
request._method = method.upper()
|
||||
request = clone_request(request, method)
|
||||
if not view.has_permission(request):
|
||||
request._method = temp
|
||||
return # Don't have permission
|
||||
request._method = temp
|
||||
|
||||
if method == 'DELETE' or method == 'OPTIONS':
|
||||
return True # Don't actually need to return a form
|
||||
|
|
|
@ -28,6 +28,22 @@ def _hasattr(obj, name):
|
|||
return not getattr(obj, name) is Empty
|
||||
|
||||
|
||||
def clone_request(request, method):
|
||||
"""
|
||||
Internal helper method to clone a request, replacing with a different
|
||||
HTTP method. Used for checking permissions against other methods.
|
||||
"""
|
||||
ret = Request(request._request,
|
||||
request.parser_classes,
|
||||
request.authentication_classes)
|
||||
ret._data = request._data
|
||||
ret._files = request._files
|
||||
ret._content_type = request._content_type
|
||||
ret._stream = request._stream
|
||||
ret._method = method
|
||||
return ret
|
||||
|
||||
|
||||
class Request(object):
|
||||
"""
|
||||
Wrapper allowing to enhance a standard `HttpRequest` instance.
|
||||
|
|
|
@ -7,6 +7,4 @@ modules = [filename.rsplit('.', 1)[0]
|
|||
__test__ = dict()
|
||||
|
||||
for module in modules:
|
||||
exec("from rest_framework.tests.%s import __doc__ as module_doc" % module)
|
||||
exec("from rest_framework.tests.%s import *" % module)
|
||||
__test__[module] = module_doc or ""
|
||||
|
|
Loading…
Reference in New Issue
Block a user