22
33import logging
44
5- import httpretty
65import pytest
6+ from mocket import Mocketizer
7+ from mocket .mockhttp import Entry
8+ from mocket .plugins .httpretty import httprettified , httpretty
79
810from scout_apm .compat import urllib3_cert_pool_manager
911from 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" )
7376def 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
104107def 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!"
0 commit comments