diff options
author | ianb <devnull@localhost> | 2007-08-11 19:19:43 +0000 |
---|---|---|
committer | ianb <devnull@localhost> | 2007-08-11 19:19:43 +0000 |
commit | a4238b8445432a8727f5b8904fa9e79c30c29f7e (patch) | |
tree | 59d6f3d265c3720e0a7f73c09ce801bcc14cb683 | |
parent | 5e227aa05325cc571cdfb601630e46cb1c2e3e3e (diff) | |
download | webtest-a4238b8445432a8727f5b8904fa9e79c30c29f7e.tar.gz |
Added a more useful __repr__ to TestResponse
-rw-r--r-- | webtest/__init__.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/webtest/__init__.py b/webtest/__init__.py index 35dfaac..756bd24 100644 --- a/webtest/__init__.py +++ b/webtest/__init__.py @@ -688,6 +688,25 @@ class TestResponse(Response): '\n'.join(['%s: %s' % (n, v) for n, v in self.headerlist]), simple_body) + def __repr__(self): + # Specifically intended for doctests + if self.content_type: + ct = ' %s' % self.content_type + else: + ct = '' + if self.body: + br = repr(self.body) + if len(br) > 18: + br = br[:10]+'...'+br[-5:] + body = ' body=%s/%s' % (br, len(self.body)) + else: + body = ' no body' + if self.location: + location = ' location: %s' % self.location + else: + location = '' + return ('<' + self.status + ct + location + body + '>') + def showbrowser(self): """ Show this response in a browser window (for debugging purposes, |