From ba5fb03646f6318a0ace286da746b4bb32f75d5a Mon Sep 17 00:00:00 2001 From: harlowja Date: Thu, 21 Jun 2012 23:35:07 -0700 Subject: Fixup python selinux guards, only try to restore after we check if its useful to restore, fix test to work with selinux enabled sysystems --- tests/unittests/test_util.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'tests/unittests') 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 -- cgit v1.2.3