summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Patterson <cpatterson@microsoft.com>2023-03-23 11:18:38 -0400
committerGitHub <noreply@github.com>2023-03-23 09:18:38 -0600
commite54ca3add327e09dbe40929c9ac16e1cefa37cf5 (patch)
treec17b7d3e66c3e6abb035a8198e52cf6ff0e12b35
parentceb66d4552e6c4c0da60cb08fdf208fb90c34660 (diff)
downloadcloud-init-git-e54ca3add327e09dbe40929c9ac16e1cefa37cf5.tar.gz
tests/sources: patch util.get_cmdline() for datasource tests (#2091)
Recent changes to override_ds_detect() triggers a call to get_cmdline(), which invokes subp.subp() for various container checks. This causes tests to fail when running a specific test module instead of the full set. This is because test_smartos.py on module load will trigger these calls and the lru_cache() will retain the results. So if the module does not load, the tests will fail. Patch util.get_cmdline() for all data source tests to avoid this behavior. Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
-rw-r--r--tests/unittests/sources/conftest.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/unittests/sources/conftest.py b/tests/unittests/sources/conftest.py
new file mode 100644
index 00000000..ef4d7e61
--- /dev/null
+++ b/tests/unittests/sources/conftest.py
@@ -0,0 +1,9 @@
+from unittest import mock
+
+import pytest
+
+
+@pytest.fixture(autouse=True)
+def mock_util_get_cmdline():
+ with mock.patch("cloudinit.util.get_cmdline", return_value="") as m:
+ yield m