Commit 84f77580 by Tom Christie

Remove support for doctests

parent aeeb68f6
...@@ -5,13 +5,13 @@ Django REST framework also provides HTML and PlainText renderers that help self- ...@@ -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, 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. and providing forms and links depending on the allowed methods, renderers and parsers on the View.
""" """
import copy
import string import string
from django import forms from django import forms
from django.template import RequestContext, loader from django.template import RequestContext, loader
from django.utils import simplejson as json from django.utils import simplejson as json
from rest_framework.compat import yaml from rest_framework.compat import yaml
from rest_framework.settings import api_settings 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 dict2xml
from rest_framework.utils import encoders from rest_framework.utils import encoders
from rest_framework.utils.breadcrumbs import get_breadcrumbs from rest_framework.utils.breadcrumbs import get_breadcrumbs
...@@ -227,12 +227,9 @@ class DocumentingHTMLRenderer(BaseRenderer): ...@@ -227,12 +227,9 @@ class DocumentingHTMLRenderer(BaseRenderer):
if not api_settings.FORM_METHOD_OVERRIDE: if not api_settings.FORM_METHOD_OVERRIDE:
return # Cannot use form overloading return # Cannot use form overloading
temp = request._method request = clone_request(request, method)
request._method = method.upper()
if not view.has_permission(request): if not view.has_permission(request):
request._method = temp
return # Don't have permission return # Don't have permission
request._method = temp
if method == 'DELETE' or method == 'OPTIONS': if method == 'DELETE' or method == 'OPTIONS':
return True # Don't actually need to return a form return True # Don't actually need to return a form
......
...@@ -28,6 +28,22 @@ def _hasattr(obj, name): ...@@ -28,6 +28,22 @@ def _hasattr(obj, name):
return not getattr(obj, name) is Empty 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): class Request(object):
""" """
Wrapper allowing to enhance a standard `HttpRequest` instance. Wrapper allowing to enhance a standard `HttpRequest` instance.
......
...@@ -7,6 +7,4 @@ modules = [filename.rsplit('.', 1)[0] ...@@ -7,6 +7,4 @@ modules = [filename.rsplit('.', 1)[0]
__test__ = dict() __test__ = dict()
for module in modules: for module in modules:
exec("from rest_framework.tests.%s import __doc__ as module_doc" % module)
exec("from rest_framework.tests.%s import *" % module) exec("from rest_framework.tests.%s import *" % module)
__test__[module] = module_doc or ""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment