summaryrefslogtreecommitdiff
path: root/conftest.py
diff options
context:
space:
mode:
authorAlberto Contreras <alberto.contreras@canonical.com>2022-09-19 15:30:54 +0200
committerGitHub <noreply@github.com>2022-09-19 08:30:54 -0500
commit9aa4ec6982541f5425c860010fa87134e58469e6 (patch)
tree40d0f3b04053a47f4f546fa8311eecfbacff2b2f /conftest.py
parent4b12fe22d0e6adf92797fec929f58c54a7d3a620 (diff)
downloadcloud-init-git-9aa4ec6982541f5425c860010fa87134e58469e6.tar.gz
tests: Drop httpretty in favor of responses (#1720)
Diffstat (limited to 'conftest.py')
-rw-r--r--conftest.py25
1 files changed, 4 insertions, 21 deletions
diff --git a/conftest.py b/conftest.py
index 3979eb0a..83dfca68 100644
--- a/conftest.py
+++ b/conftest.py
@@ -7,7 +7,6 @@ Any imports that are performed at the top-level here must be installed wherever
any of these tests run: that is to say, they must be listed in
``integration-requirements.txt`` and in ``test-requirements.txt``.
"""
-import os
from unittest import mock
import pytest
@@ -167,27 +166,11 @@ def fixture_utils():
@pytest.fixture
-def httpretty():
- """
- Enable HTTPretty for duration of the testcase, resetting before and after.
-
- This will also ensure allow_net_connect is set to False, and temporarily
- unset http_proxy in os.environ if present (to work around
- https://github.com/gabrielfalcao/HTTPretty/issues/122).
- """
- import httpretty as _httpretty
-
- restore_proxy = os.environ.pop("http_proxy", None)
- _httpretty.HTTPretty.allow_net_connect = False
- _httpretty.reset()
- _httpretty.enable()
-
- yield _httpretty
+def mocked_responses():
+ import responses as _responses
- _httpretty.disable()
- _httpretty.reset()
- if restore_proxy is not None:
- os.environ["http_proxy"] = restore_proxy
+ with _responses.RequestsMock(assert_all_requests_are_fired=False) as rsps:
+ yield rsps
@pytest.fixture