summaryrefslogtreecommitdiff
path: root/conftest.py
diff options
context:
space:
mode:
authorDaniel Watkins <oddbloke@ubuntu.com>2020-10-06 10:52:20 -0400
committerGitHub <noreply@github.com>2020-10-06 08:52:20 -0600
commit5435205decf3c8582258d0782dc54aebdd154212 (patch)
treecfdb970309fa6aa8c8c9a1978ccec072da5e651e /conftest.py
parentb4f1abf9a2470adf447d8032a56a0ee17947f929 (diff)
downloadvyos-cloud-init-5435205decf3c8582258d0782dc54aebdd154212.tar.gz
vyos-cloud-init-5435205decf3c8582258d0782dc54aebdd154212.zip
conftest.py: remove top-level import of httpretty (#599)
This means that the integration tests do not need to install test-requirements.txt in order to successfully import `conftest.py`.
Diffstat (limited to 'conftest.py')
-rw-r--r--conftest.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/conftest.py b/conftest.py
index 76e9000a..459b708a 100644
--- a/conftest.py
+++ b/conftest.py
@@ -1,8 +1,16 @@
+"""Global conftest.py
+
+This conftest is used for unit tests in ``cloudinit/`` and ``tests/unittests/``
+as well as the integration tests in ``tests/integration_tests/``.
+
+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
-import httpretty as _httpretty
from cloudinit import helpers, subp
@@ -156,6 +164,8 @@ def httpretty():
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()