mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Add Request repr (#7239)
This commit is contained in:
parent
57e7cc21e1
commit
dd33ebb4e2
|
@ -179,6 +179,13 @@ class Request:
|
||||||
forced_auth = ForcedAuthentication(force_user, force_token)
|
forced_auth = ForcedAuthentication(force_user, force_token)
|
||||||
self.authenticators = (forced_auth,)
|
self.authenticators = (forced_auth,)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return '<%s.%s: %s %r>' % (
|
||||||
|
self.__class__.__module__,
|
||||||
|
self.__class__.__name__,
|
||||||
|
self.method,
|
||||||
|
self.get_full_path())
|
||||||
|
|
||||||
def _default_negotiator(self):
|
def _default_negotiator(self):
|
||||||
return api_settings.DEFAULT_CONTENT_NEGOTIATION_CLASS()
|
return api_settings.DEFAULT_CONTENT_NEGOTIATION_CLASS()
|
||||||
|
|
||||||
|
|
|
@ -272,6 +272,12 @@ class TestSecure(TestCase):
|
||||||
|
|
||||||
|
|
||||||
class TestHttpRequest(TestCase):
|
class TestHttpRequest(TestCase):
|
||||||
|
def test_repr(self):
|
||||||
|
http_request = factory.get('/path')
|
||||||
|
request = Request(http_request)
|
||||||
|
|
||||||
|
assert repr(request) == "<rest_framework.request.Request: GET '/path'>"
|
||||||
|
|
||||||
def test_attribute_access_proxy(self):
|
def test_attribute_access_proxy(self):
|
||||||
http_request = factory.get('/')
|
http_request = factory.get('/')
|
||||||
request = Request(http_request)
|
request = Request(http_request)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user