diff --git a/tests/unittests/conftest.py b/tests/unittests/conftest.py index f8f06d420095..df41afe351d4 100644 --- a/tests/unittests/conftest.py +++ b/tests/unittests/conftest.py @@ -88,18 +88,8 @@ def fake_filesystem(mocker, tmpdir): @pytest.fixture(scope="session", autouse=True) -def disable_sysfs_net(request, tmpdir_factory): - """Avoid tests which read the undertying host's /syc/class/net. - - To allow unobscured reads of /sys/class/net on the host we can - parametrize the fixture with: - - @pytest.mark.parametrize("disable_sysfs_net", [False], indirect=True) - """ - if hasattr(request, "param") and getattr(request, "param") is False: - # Test disabled this fixture, perform no mocks. - yield - return +def disable_sysfs_net(tmpdir_factory): + """Avoid tests which read the undertying host's /syc/class/net.""" mock_sysfs = f"{tmpdir_factory.mktemp('sysfs')}/" with mock.patch( "cloudinit.net.get_sys_class_path", return_value=mock_sysfs diff --git a/tests/unittests/net/test_init.py b/tests/unittests/net/test_init.py index 67621b1c0bc2..85625448733f 100644 --- a/tests/unittests/net/test_init.py +++ b/tests/unittests/net/test_init.py @@ -43,10 +43,7 @@ def test_sys_dev_path_without_path(self): class TestReadSysNet: @pytest.fixture(autouse=True) - @pytest.mark.parametrize( - "disable_sysfs_net", [False], indirect=["disable_sysfs_net"] - ) - def setup(self, disable_sysfs_net, tmpdir_factory): + def setup(self, tmpdir_factory): # We mock invididual numbered tmpdirs here because these tests write # to the sysfs directory and stale test artifacts break later tests. mock_sysfs = f"{tmpdir_factory.mktemp('sysfs', numbered=True)}/"