@@ -149,14 +149,20 @@ def __init__(self, uri, method, responses, match_querystring=True):
149149 self ._match_querystring = match_querystring
150150
151151 def collect (self , data ):
152+ consume_response = True
153+
152154 decoded_data = decode_from_bytes (data )
153155 if not decoded_data .startswith (Entry .METHODS ):
154156 Mocket .remove_last_request ()
155157 self ._sent_data += data
158+ consume_response = False
156159 else :
157160 self ._sent_data = data
161+
158162 super (Entry , self ).collect (self ._sent_data )
159163
164+ return consume_response
165+
160166 def can_handle (self , data ):
161167 r"""
162168 >>> e = Entry('http://www.github.com/?bar=foo&foobar', Entry.GET, (Response(b'<html/>'),))
@@ -170,10 +176,8 @@ def can_handle(self, data):
170176 requestline , _ = decode_from_bytes (data ).split (CRLF , 1 )
171177 method , path , version = self ._parse_requestline (requestline )
172178 except ValueError :
173- try :
174- return self == Mocket ._last_entry
175- except AttributeError :
176- return False
179+ return self is getattr (Mocket , "_last_entry" , None )
180+
177181 uri = urlsplit (path )
178182 can_handle = uri .path == self .path and method == self .method
179183 if self ._match_querystring :
@@ -240,5 +244,8 @@ def single_register(
240244 )
241245
242246 cls .register (
243- method , uri , response , match_querystring = match_querystring ,
247+ method ,
248+ uri ,
249+ response ,
250+ match_querystring = match_querystring ,
244251 )
0 commit comments