summaryrefslogtreecommitdiff
path: root/tests/functional/test_fakesocket.py
diff options
context:
space:
mode:
authorGabriel Falcão <gabriel@nacaolivre.org>2018-11-04 23:34:43 +0100
committerGabriel Falcão <gabriel@nacaolivre.org>2018-11-04 23:34:43 +0100
commit067c4bda72a442e1771374f9d69a5a1c77c88de5 (patch)
tree907b5303ea0c77fbc64daa67e79920577c8edc2f /tests/functional/test_fakesocket.py
parent2314893ec5ab46513e91ab867d7b55a72968909e (diff)
downloadhttpretty-black.tar.gz
prettify code with blackblack
Diffstat (limited to 'tests/functional/test_fakesocket.py')
-rw-r--r--tests/functional/test_fakesocket.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/tests/functional/test_fakesocket.py b/tests/functional/test_fakesocket.py
index 215d074..edacd77 100644
--- a/tests/functional/test_fakesocket.py
+++ b/tests/functional/test_fakesocket.py
@@ -36,6 +36,7 @@ class FakeSocket(socket.socket):
Just an editable socket factory
It allows mock to patch readonly functions
"""
+
connect = sendall = lambda *args, **kw: None
@@ -50,26 +51,24 @@ def recv(flag, size):
the asked size passed in argument.
Any further call will just raise RuntimeError
"""
- if 'was_here' in flag:
- raise RuntimeError('Already sent everything')
+ if "was_here" in flag:
+ raise RuntimeError("Already sent everything")
else:
- flag['was_here'] = None
- return 'a' * (size - 1)
+ flag["was_here"] = None
+ return "a" * (size - 1)
recv = functools.partial(recv, fake_socket_interupter_flag)
-@mock.patch('httpretty.old_socket', new=FakeSocket)
+@mock.patch("httpretty.old_socket", new=FakeSocket)
def _test_shorten_response():
u"HTTPretty shouldn't try to read from server when communication is over"
from sure import expect
import httpretty
- fakesocket = httpretty.fakesock.socket(socket.AF_INET,
- socket.SOCK_STREAM)
- with mock.patch.object(fakesocket.truesock, 'recv', recv):
- fakesocket.connect(('localhost', 80))
- fakesocket._true_sendall('WHATEVER')
- expect(fakesocket.fd.read()).to.equal(
- 'a' * (httpretty.socket_buffer_size - 1))
+ fakesocket = httpretty.fakesock.socket(socket.AF_INET, socket.SOCK_STREAM)
+ with mock.patch.object(fakesocket.truesock, "recv", recv):
+ fakesocket.connect(("localhost", 80))
+ fakesocket._true_sendall("WHATEVER")
+ expect(fakesocket.fd.read()).to.equal("a" * (httpretty.socket_buffer_size - 1))