diff options
author | harlowja <harlowja@virtualbox.rhel> | 2012-06-21 23:35:07 -0700 |
---|---|---|
committer | harlowja <harlowja@virtualbox.rhel> | 2012-06-21 23:35:07 -0700 |
commit | ba5fb03646f6318a0ace286da746b4bb32f75d5a (patch) | |
tree | 093ee35fab7f54a928aa49b48b1a8529b6ced401 /tests | |
parent | 23cf7e35bf9aa1cffc9d1bb2f20d362b57110723 (diff) | |
download | vyos-cloud-init-ba5fb03646f6318a0ace286da746b4bb32f75d5a.tar.gz vyos-cloud-init-ba5fb03646f6318a0ace286da746b4bb32f75d5a.zip |
Fixup python selinux guards, only try to restore after we check if its useful to restore, fix test to work with selinux enabled sysystems
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/test_util.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py index ba565b29..3be6e186 100644 --- a/tests/unittests/test_util.py +++ b/tests/unittests/test_util.py @@ -71,7 +71,7 @@ class TestGetCfgOptionListOrStr(TestCase): """None is returned if key is not found and no default given.""" config = {} result = util.get_cfg_option_list(config, "key") - self.assertIsNone(result) + self.assertEqual(None, result) def test_not_found_with_default(self): """Default is returned if key is not found.""" @@ -166,14 +166,13 @@ class TestWriteFile(MockerTestCase): "selinux.restorecon", passthrough=False) mock_is_selinux_enabled = self.mocker.replace( "selinux.is_selinux_enabled", passthrough=False) - mock_is_selinux_enabled.result(True) - mock_restorecon(path) + mock_is_selinux_enabled() + self.mocker.result(True) + mock_restorecon("/etc/hosts", recursive=False) + self.mocker.result(True) self.mocker.replay() - old = util.HAVE_LIBSELINUX - util.HAVE_LIBSELINUX = True - with util.SeLinuxGuard(self.tmp) as is_on: + with util.SeLinuxGuard("/etc/hosts") as is_on: self.assertTrue(is_on) - util.HAVE_LIBSELINUX = old except ImportError: pass |