adding a dummy last_request for the sake of meaningful assertion errors
This commit is contained in:
@@ -86,6 +86,15 @@ class HTTPrettyRequest(BaseHTTPRequestHandler):
|
||||
)
|
||||
|
||||
|
||||
class EmptyRequestHeaders(dict):
|
||||
pass
|
||||
|
||||
|
||||
class HTTPrettyRequestEmpty(object):
|
||||
body = ''
|
||||
headers = EmptyRequestHeaders()
|
||||
|
||||
|
||||
class FakeSockFile(StringIO):
|
||||
def read(self, amount=None):
|
||||
amount = amount or self.len
|
||||
@@ -236,8 +245,10 @@ class fakesock(object):
|
||||
if entry.method == method:
|
||||
self._entry = entry
|
||||
|
||||
sendto = send = recvfrom_into = recv_into = recvfrom = recv = \
|
||||
lambda *a, **kw: None
|
||||
def debug(*a, **kw):
|
||||
import debug
|
||||
|
||||
sendto = send = recvfrom_into = recv_into = recvfrom = recv = debug
|
||||
|
||||
|
||||
def fake_wrap_socket(s, *args, **kw):
|
||||
@@ -500,6 +511,7 @@ class HTTPretty(object):
|
||||
DELETE = 'DELETE'
|
||||
HEAD = 'HEAD'
|
||||
PATCH = 'PATCH'
|
||||
last_request = HTTPrettyRequestEmpty()
|
||||
|
||||
@classmethod
|
||||
def historify_request(cls, headers, body=''):
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
from sure import that
|
||||
from httpretty import HTTPretty, HTTPrettyError
|
||||
|
||||
|
||||
def test_httpretty_should_raise_proper_exception_on_inconsistent_length():
|
||||
u"HTTPretty should raise proper exception on inconsistent Content-Length / "\
|
||||
"registered response body"
|
||||
@@ -48,3 +49,10 @@ def test_httpretty_should_raise_proper_exception_on_inconsistent_length():
|
||||
'but the body you registered for that has actually length "10".\n'
|
||||
'Fix that, or if you really want that, call register_uri with "fill_with" callback.'
|
||||
)
|
||||
|
||||
|
||||
def test_does_not_have_last_request_by_default():
|
||||
u'HTTPretty.last_request is a dummy object by default'
|
||||
|
||||
assert that(HTTPretty.last_request.headers).is_empty
|
||||
assert that(HTTPretty.last_request.body).is_empty
|
||||
|
||||
Reference in New Issue
Block a user