diff options
author | Chris Patterson <cpatterson@microsoft.com> | 2023-03-23 11:18:38 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-23 09:18:38 -0600 |
commit | e54ca3add327e09dbe40929c9ac16e1cefa37cf5 (patch) | |
tree | c17b7d3e66c3e6abb035a8198e52cf6ff0e12b35 | |
parent | ceb66d4552e6c4c0da60cb08fdf208fb90c34660 (diff) | |
download | cloud-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.py | 9 |
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 |