Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to unittest.mock everywhere #452

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ httplib2>=0.17.0
httpx>=0.18.1
ipdb>=0.13.2
mccabe>=0.6.1
mock>=3.0.5;python_version<"3.3"
ndg-httpsclient>=0.5.1
nose-randomly>=1.2.6
nose>=1.3.7
Expand Down
4 changes: 0 additions & 4 deletions tests/compat.py

This file was deleted.

6 changes: 3 additions & 3 deletions tests/functional/test_fakesocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import functools
import socket

import mock
from unittest.mock import patch


class FakeSocket(socket.socket):
Expand Down Expand Up @@ -60,15 +60,15 @@ 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
import httpretty

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(
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
from tornado import version as tornado_version
from httpretty import HTTPretty, httprettified
from httpretty.core import decode_utf8
from unittest.mock import Mock

from tests.functional.base import FIXTURE_FILE, use_tornado_server

from tests.compat import Mock


try:
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/test_core.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import io
import json
import errno
from unittest.mock import Mock, patch, call

from freezegun import freeze_time
from sure import expect

from httpretty.core import HTTPrettyRequest, FakeSSLSocket, fakesock, httpretty
from httpretty.core import URIMatcher, URIInfo

from tests.compat import Mock, patch, call


class SocketErrorStub(Exception):
def __init__(self, errno):
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/test_httpretty.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@
import re
import json
from sure import expect
from unittest.mock import MagicMock, patch
import httpretty
from httpretty import HTTPretty
from httpretty import HTTPrettyError
from httpretty import core
from httpretty.core import URIInfo, BaseClass, Entry, FakeSockFile, HTTPrettyRequest
from httpretty.http import STATUSES

from tests.compat import MagicMock, patch


TEST_HEADER = """
GET /test/test.html HTTP/1.1
Expand Down