summaryrefslogtreecommitdiff
path: root/conftest.py
diff options
context:
space:
mode:
Diffstat (limited to 'conftest.py')
-rw-r--r--conftest.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/conftest.py b/conftest.py
index 9e9d9ff8..3979eb0a 100644
--- a/conftest.py
+++ b/conftest.py
@@ -12,7 +12,7 @@ from unittest import mock
import pytest
-from cloudinit import helpers, subp
+from cloudinit import helpers, subp, util
class _FixtureUtils:
@@ -65,7 +65,7 @@ class _FixtureUtils:
return result[0]
-@pytest.yield_fixture(autouse=True)
+@pytest.fixture(autouse=True)
def disable_subp_usage(request, fixture_utils):
"""
Across all (pytest) tests, ensure that subp.subp is not invoked.
@@ -138,6 +138,7 @@ def disable_subp_usage(request, fixture_utils):
" this either by modifying your test code, or by modifying"
" disable_subp_usage to handle precedence."
)
+
else:
# Look this up before our patch is in place, so we have access to
# the real implementation in side_effect
@@ -165,7 +166,7 @@ def fixture_utils():
return _FixtureUtils
-@pytest.yield_fixture
+@pytest.fixture
def httpretty():
"""
Enable HTTPretty for duration of the testcase, resetting before and after.
@@ -201,3 +202,19 @@ def paths(tmpdir):
"run_dir": tmpdir.mkdir("run_dir").strpath,
}
return helpers.Paths(dirs)
+
+
+@pytest.fixture(autouse=True, scope="session")
+def monkeypatch_system_info():
+ def my_system_info():
+ return {
+ "platform": "invalid",
+ "system": "invalid",
+ "release": "invalid",
+ "python": "invalid",
+ "uname": ["invalid"] * 6,
+ "dist": ("Distro", "-1.1", "Codename"),
+ "variant": "ubuntu",
+ }
+
+ util.system_info = my_system_info