summaryrefslogtreecommitdiff
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
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`.
-rw-r--r--conftest.py12
-rw-r--r--tox.ini2
2 files changed, 11 insertions, 3 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()
diff --git a/tox.ini b/tox.ini
index 1160072a..a8681197 100644
--- a/tox.ini
+++ b/tox.ini
@@ -141,10 +141,8 @@ deps =
basepython = python3
commands = {envpython} -m pytest --log-cli-level=INFO {posargs:tests/integration_tests}
passenv = CLOUD_INIT_*
-# test-requirements.txt is required for ./conftest.py to import successfully
deps =
-r{toxinidir}/integration-requirements.txt
- -r{toxinidir}/test-requirements.txt
[pytest]
# TODO: s/--strict/--strict-markers/ once xenial support is dropped