Skip to content

Commit 7c09e09

Browse files
committed
Swap in mocket for httpretty
1 parent ef9bf91 commit 7c09e09

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

tests/integration/instruments/test_urllib3.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import logging
44

5-
import httpretty
65
import pytest
6+
from mocket import Mocketizer
7+
from mocket.mockhttp import Entry
8+
from mocket.plugins.httpretty import httprettified, httpretty
79

810
from scout_apm.compat import urllib3_cert_pool_manager
911
from scout_apm.instruments.urllib3 import ensure_installed
@@ -70,13 +72,12 @@ def test_install_fail_no_urlopen_attribute(caplog):
7072
)
7173

7274

75+
@pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning")
7376
def test_request(tracked_request):
7477
ensure_installed()
75-
with httpretty.enabled(allow_net_connect=False):
76-
httpretty.register_uri(
77-
httpretty.GET, "https://example.com/", body="Hello World!"
78-
)
78+
Entry.single_register(Entry.GET, "https://example.com/", body="Hello World!")
7979

80+
with Mocketizer(strict_mode=True):
8081
http = urllib3_cert_pool_manager()
8182
response = http.request("GET", "https://example.com")
8283

@@ -101,15 +102,16 @@ def test_request_type_error(tracked_request):
101102
assert span.tags["url"] == "https://example.com:443/"
102103

103104

105+
@pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning")
106+
@httprettified
104107
def test_request_ignore_errors_host(tracked_request):
105108
ensure_installed()
106-
with httpretty.enabled(allow_net_connect=False):
107-
httpretty.register_uri(
108-
httpretty.POST, "https://errors.scoutapm.com", body="Hello World!"
109-
)
109+
httpretty.register_uri(
110+
httpretty.POST, "https://errors.scoutapm.com", body="Hello World!"
111+
)
110112

111-
http = urllib3_cert_pool_manager()
112-
response = http.request("POST", "https://errors.scoutapm.com")
113+
http = urllib3_cert_pool_manager()
114+
response = http.request("POST", "https://errors.scoutapm.com")
113115

114116
assert response.status == 200
115117
assert response.data == b"Hello World!"

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ deps =
3333
hiredis
3434
huey
3535
hug>=2.5.1
36-
httpretty
3736
importlib_metadata
3837
jinja2
38+
mocket
3939
psutil
4040
pymongo
4141
pyramid

0 commit comments

Comments
 (0)