Commit a7e182f9 by Bjorn Neergaard

tests: properly use and cleanup httpretty

parent 27531c1f
......@@ -275,13 +275,9 @@ def git_mock(mocker: MockerFixture) -> None:
@pytest.fixture
def http() -> Iterator[type[httpretty.httpretty]]:
httpretty.reset()
httpretty.enable(allow_net_connect=False)
with httpretty.enabled(allow_net_connect=False):
yield httpretty
httpretty.activate()
httpretty.reset()
@pytest.fixture
def fixture_base() -> Path:
......
......@@ -215,7 +215,7 @@ def test_authenticator_request_retries_on_exception(
raise requests.exceptions.ConnectionError("Disconnected")
return [200, response_headers, content]
httpretty.register_uri(httpretty.GET, sdist_uri, body=callback)
http.register_uri(httpretty.GET, sdist_uri, body=callback)
authenticator = Authenticator(config, NullIO())
response = authenticator.request("get", sdist_uri)
......@@ -233,7 +233,7 @@ def test_authenticator_request_raises_exception_when_attempts_exhausted(
def callback(*_: Any, **___: Any) -> None:
raise requests.exceptions.ConnectionError(str(uuid.uuid4()))
httpretty.register_uri(httpretty.GET, sdist_uri, body=callback)
http.register_uri(httpretty.GET, sdist_uri, body=callback)
authenticator = Authenticator(config, NullIO())
with pytest.raises(requests.exceptions.ConnectionError):
......@@ -271,7 +271,7 @@ def test_authenticator_request_retries_on_status_code(
) -> list[int | dict | str]:
return [status, response_headers, content]
httpretty.register_uri(httpretty.GET, sdist_uri, body=callback)
http.register_uri(httpretty.GET, sdist_uri, body=callback)
authenticator = Authenticator(config, NullIO())
with pytest.raises(requests.exceptions.HTTPError) as excinfo:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment