Skip to content

Commit d0b43a1

Browse files
authored
Increasing readability of Mocket core. (#258)
1 parent ea5ad79 commit d0b43a1

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

mocket/mocket.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -370,18 +370,15 @@ def true_sendall(self, data, *args, **kwargs):
370370
self.true_socket.connect((host, port))
371371
self.true_socket.sendall(data, *args, **kwargs)
372372
encoded_response = b""
373-
# https://github.com/kennethreitz/requests/blob/master/tests/testserver/server.py#L13
373+
# https://github.com/kennethreitz/requests/blob/master/tests/testserver/server.py#L12
374374
while True:
375-
if (
376-
not select.select([self.true_socket], [], [], 0.1)[0]
377-
and encoded_response
378-
):
375+
more_to_read = select.select([self.true_socket], [], [], 0.1)[0]
376+
if not more_to_read and encoded_response:
379377
break
380-
recv = self.true_socket.recv(self._buflen)
381-
382-
if not recv and encoded_response:
378+
new_content = self.true_socket.recv(self._buflen)
379+
if not new_content:
383380
break
384-
encoded_response += recv
381+
encoded_response += new_content
385382

386383
# dump the resulting dictionary to a JSON file
387384
if Mocket.get_truesocket_recording_dir():

0 commit comments

Comments
 (0)