forked from pool/python-httpretty
aed3316871
* Use unittest.mock in the functional tests. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-httpretty?expand=0&rev=45
35 lines
1.2 KiB
Diff
35 lines
1.2 KiB
Diff
Index: httpretty-1.1.4/tests/functional/test_fakesocket.py
|
|
===================================================================
|
|
--- httpretty-1.1.4.orig/tests/functional/test_fakesocket.py
|
|
+++ httpretty-1.1.4/tests/functional/test_fakesocket.py
|
|
@@ -28,7 +28,10 @@
|
|
import functools
|
|
import socket
|
|
|
|
-import mock
|
|
+try:
|
|
+ from unittest.mock import patch
|
|
+except ImportError:
|
|
+ from mock import patch
|
|
|
|
|
|
class FakeSocket(socket.socket):
|
|
@@ -60,7 +63,7 @@ def recv(flag, size):
|
|
recv = functools.partial(recv, fake_socket_interupter_flag)
|
|
|
|
|
|
-@mock.patch('httpretty.old_socket', new=FakeSocket)
|
|
+@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
|
|
@@ -68,7 +71,7 @@ def _test_shorten_response():
|
|
|
|
fakesocket = httpretty.fakesock.socket(socket.AF_INET,
|
|
socket.SOCK_STREAM)
|
|
- with mock.patch.object(fakesocket.truesock, 'recv', recv):
|
|
+ with patch.object(fakesocket.truesock, 'recv', recv):
|
|
fakesocket.connect(('localhost', 80))
|
|
fakesocket._true_sendall('WHATEVER')
|
|
expect(fakesocket.fd.read()).to.equal(
|