From adb1dea6c911fb89d2b21b461f4f04183e09ab08 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Sun, 9 Jun 2024 16:31:07 +0200 Subject: [PATCH] remove python2 cruft & ancient mock --- development.txt | 1 - httpretty/errors.py | 1 - httpretty/http.py | 2 -- tests/__init__.py | 1 - tests/compat.py | 4 ---- tests/functional/base.py | 2 -- tests/functional/test_bypass.py | 1 - tests/functional/test_fakesocket.py | 3 +-- tests/functional/test_httplib2.py | 3 +-- tests/functional/test_requests.py | 3 +-- tests/functional/test_urllib2.py | 2 -- tests/functional/testserver.py | 2 -- tests/pyopenssl/test_mock.py | 2 -- tests/unit/test_core.py | 2 +- tests/unit/test_http.py | 1 - tests/unit/test_httpretty.py | 6 +++--- tests/unit/test_main.py | 8 ++------ 17 files changed, 9 insertions(+), 35 deletions(-) delete mode 100644 tests/compat.py diff --git a/development.txt b/development.txt index 08eeb362..883985f7 100644 --- a/development.txt +++ b/development.txt @@ -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 diff --git a/httpretty/errors.py b/httpretty/errors.py index 149c6c6e..b08dced2 100644 --- a/httpretty/errors.py +++ b/httpretty/errors.py @@ -24,7 +24,6 @@ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -from __future__ import unicode_literals import json class HTTPrettyError(Exception): diff --git a/httpretty/http.py b/httpretty/http.py index 0f75935a..e827342f 100644 --- a/httpretty/http.py +++ b/httpretty/http.py @@ -23,8 +23,6 @@ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -from __future__ import unicode_literals - import re from .compat import BaseClass from .utils import decode_utf8 diff --git a/tests/__init__.py b/tests/__init__.py index 90474651..cad9e68a 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +1,3 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from __future__ import unicode_literals import sure diff --git a/tests/compat.py b/tests/compat.py deleted file mode 100644 index 8a6c9033..00000000 --- a/tests/compat.py +++ /dev/null @@ -1,4 +0,0 @@ -try: - from unittest.mock import Mock, patch, call, MagicMock -except ImportError: - from mock import Mock, patch, call, MagicMock diff --git a/tests/functional/base.py b/tests/functional/base.py index 7d2ecee9..bcc0ef57 100644 --- a/tests/functional/base.py +++ b/tests/functional/base.py @@ -25,8 +25,6 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -from __future__ import unicode_literals - import os import json import socket diff --git a/tests/functional/test_bypass.py b/tests/functional/test_bypass.py index e85dfac2..5745d00e 100644 --- a/tests/functional/test_bypass.py +++ b/tests/functional/test_bypass.py @@ -24,7 +24,6 @@ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -from __future__ import unicode_literals import time import requests try: diff --git a/tests/functional/test_fakesocket.py b/tests/functional/test_fakesocket.py index 39d914b0..32003c44 100644 --- a/tests/functional/test_fakesocket.py +++ b/tests/functional/test_fakesocket.py @@ -27,8 +27,7 @@ import functools import socket - -import mock +from unittest import mock class FakeSocket(socket.socket): diff --git a/tests/functional/test_httplib2.py b/tests/functional/test_httplib2.py index c913d8a8..c586837c 100644 --- a/tests/functional/test_httplib2.py +++ b/tests/functional/test_httplib2.py @@ -24,9 +24,8 @@ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -from __future__ import unicode_literals - import re + import httplib2 from freezegun import freeze_time from sure import expect, within, miliseconds diff --git a/tests/functional/test_requests.py b/tests/functional/test_requests.py index 55aa109d..8ca6e941 100644 --- a/tests/functional/test_requests.py +++ b/tests/functional/test_requests.py @@ -28,6 +28,7 @@ import requests import signal import httpretty +from unittest.mock import Mock from freezegun import freeze_time from contextlib import contextmanager @@ -38,8 +39,6 @@ from tests.functional.base import FIXTURE_FILE, use_tornado_server -from tests.compat import Mock - try: advance_iterator = next diff --git a/tests/functional/test_urllib2.py b/tests/functional/test_urllib2.py index 9c8ff39f..ac54ea8f 100644 --- a/tests/functional/test_urllib2.py +++ b/tests/functional/test_urllib2.py @@ -24,8 +24,6 @@ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -from __future__ import unicode_literals - import re try: from urllib.request import urlopen diff --git a/tests/functional/testserver.py b/tests/functional/testserver.py index 623dd884..ea822100 100644 --- a/tests/functional/testserver.py +++ b/tests/functional/testserver.py @@ -24,8 +24,6 @@ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -from __future__ import unicode_literals - import os import time import socket diff --git a/tests/pyopenssl/test_mock.py b/tests/pyopenssl/test_mock.py index f98b102b..af91a573 100644 --- a/tests/pyopenssl/test_mock.py +++ b/tests/pyopenssl/test_mock.py @@ -24,8 +24,6 @@ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -from __future__ import unicode_literals - import requests from httpretty import HTTPretty, httprettified diff --git a/tests/unit/test_core.py b/tests/unit/test_core.py index 80c4a86e..869f3d61 100644 --- a/tests/unit/test_core.py +++ b/tests/unit/test_core.py @@ -1,6 +1,7 @@ import io import json import errno +from unittest.mock import Mock, patch, call from freezegun import freeze_time from sure import expect @@ -8,7 +9,6 @@ from httpretty.core import HTTPrettyRequest, FakeSSLSocket, fakesock, httpretty from httpretty.core import URIMatcher, URIInfo -from tests.compat import Mock, patch, call class SocketErrorStub(Exception): diff --git a/tests/unit/test_http.py b/tests/unit/test_http.py index 7ea5fe1d..4db134a1 100644 --- a/tests/unit/test_http.py +++ b/tests/unit/test_http.py @@ -1,6 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from __future__ import unicode_literals from httpretty.http import parse_requestline diff --git a/tests/unit/test_httpretty.py b/tests/unit/test_httpretty.py index 89b2abf2..81dc8e84 100644 --- a/tests/unit/test_httpretty.py +++ b/tests/unit/test_httpretty.py @@ -24,10 +24,12 @@ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -from __future__ import unicode_literals import re import json +from unittest.mock import MagicMock, patch + from sure import expect + import httpretty from httpretty import HTTPretty from httpretty import HTTPrettyError @@ -35,8 +37,6 @@ 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 diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index 35a7b7d1..6a906f92 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -1,14 +1,10 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from unittest.mock import patch + import httpretty from httpretty.core import HTTPrettyRequest -try: - from unittest.mock import patch -except ImportError: - from mock import patch - @patch('httpretty.httpretty') def test_last_request(original):