Add string representation to _RequestObjectProxy

Via https://github.com/openstack/requests-mock/pull/12 by @allardhoeve

Change-Id: I7e9bba3a22a08ee41af5480b8a3cee49ef06624d
This commit is contained in:
Rick van de Loo 2017-04-18 10:15:19 +02:00
parent aa3e87c4ee
commit fcc640f495
3 changed files with 8 additions and 0 deletions

1
.gitignore vendored
View File

@ -34,6 +34,7 @@ htmlcov
.mr.developer.cfg
.project
.pydevproject
.idea
# Complexity
output/*.html

View File

@ -152,3 +152,6 @@ class _RequestObjectProxy(object):
the matcher is not available it will return None.
"""
return self._matcher()
def __str__(self):
return "{0.method} {0.url}".format(self._request)

View File

@ -117,3 +117,7 @@ class RequestTests(base.TestCase):
self.assertEqual('host.example.com', req.netloc)
self.assertEqual('host.example.com', req.hostname)
self.assertEqual(443, req.port)
def test_to_string(self):
req = self.do_request(url='https://host.example.com/path')
self.assertEqual('GET https://host.example.com/path', str(req))