def restrict_http_requests(monkeypatch: pytest.MonkeyPatch) -> None:
    """
    This fixture prevents all tests from performing HTTP requests to
    any host than `localhost`.

    Any external request attempt leads to `RuntimeError` with a helpful message
    pointing developers to the `responses` fixture.
    """
    allowed_hosts = {"localhost"}
    original_urlopen = HTTPConnectionPool.urlopen

    def urlopen_mock(  # type: ignore[no-untyped-def]
        self,
        method: str,
        url: str,
        *args,
        **kwargs,
    ) -> BaseHTTPResponse:
        if self.host in allowed_hosts:
            return original_urlopen(self, method, url, *args, **kwargs)

        raise RuntimeError(
            f"Blocked {method} request to {self.scheme}://{self.host}{url}. "
            "Use `responses` fixture to mock the response!"
        )

    monkeypatch.setattr(
        "urllib3.connectionpool.HTTPConnectionPool.urlopen", urlopen_mock
    )

    This fixture prevents all tests from performing HTTP requests to
    any host than `localhost`.

    Any external request attempt leads to `RuntimeError` with a helpful message
    pointing developers to the `responses` fixture.
    
api/conftest.py