From e74a45e719cbb5445720a32c8a3ec41b306e2667 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Tue, 29 Jan 2013 08:39:11 -0500 Subject: fixed unit tests --- src/sbin/bcfg2-test | 9 +++++++-- .../Testlib/TestServer/TestPlugins/TestTemplateHelper.py | 15 ++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/sbin/bcfg2-test b/src/sbin/bcfg2-test index 4123effe4..25476c7b4 100755 --- a/src/sbin/bcfg2-test +++ b/src/sbin/bcfg2-test @@ -71,9 +71,14 @@ class ClientTest(TestCase): def get_sigint_handler(core): - def hdlr(sig, frame): + """ Get a function that handles SIGINT/Ctrl-C by shutting down the + core and exiting properly.""" + + def hdlr(sig, frame): # pylint: disable=W0613 + """ Handle SIGINT/Ctrl-C by shutting down the core and exiting + properly. """ core.shutdown() - os._exit(1) + os._exit(1) # pylint: disable=W0212 return hdlr diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestTemplateHelper.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestTemplateHelper.py index 43d594482..bf9a3ced3 100644 --- a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestTemplateHelper.py +++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestTemplateHelper.py @@ -39,7 +39,8 @@ class TestHelperModule(Bcfg2TestCase): mock_load_source.side_effect = ImportError attrs = dir(hm) hm.HandleEvent() - mock_load_source.assert_called_with(hm._module_name, hm.name) + mock_load_source.assert_called_with(safe_module_name(hm._module_name), + hm.name) self.assertEqual(attrs, dir(hm)) self.assertEqual(hm._attrs, []) @@ -50,7 +51,8 @@ class TestHelperModule(Bcfg2TestCase): mock_load_source.return_value = Mock() attrs = dir(hm) hm.HandleEvent() - mock_load_source.assert_called_with(hm._module_name, hm.name) + mock_load_source.assert_called_with(safe_module_name(hm._module_name), + hm.name) self.assertEqual(attrs, dir(hm)) self.assertEqual(hm._attrs, []) @@ -61,7 +63,8 @@ class TestHelperModule(Bcfg2TestCase): mock_load_source.return_value = module attrs = dir(hm) hm.HandleEvent() - mock_load_source.assert_called_with(hm._module_name, hm.name) + mock_load_source.assert_called_with(safe_module_name(hm._module_name), + hm.name) self.assertEqual(attrs, dir(hm)) self.assertEqual(hm._attrs, []) @@ -71,7 +74,8 @@ class TestHelperModule(Bcfg2TestCase): mock_load_source.reset() mock_load_source.return_value = module hm.HandleEvent() - mock_load_source.assert_called_with(hm._module_name, hm.name) + mock_load_source.assert_called_with(safe_module_name(hm._module_name), + hm.name) self.assertTrue(hasattr(hm, "foo")) self.assertTrue(hasattr(hm, "bar")) self.assertTrue(hasattr(hm, "baz")) @@ -83,7 +87,8 @@ class TestHelperModule(Bcfg2TestCase): mock_load_source.reset() mock_load_source.return_value = module hm.HandleEvent() - mock_load_source.assert_called_with(hm._module_name, hm.name) + mock_load_source.assert_called_with(safe_module_name(hm._module_name), + hm.name) self.assertTrue(hasattr(hm, "foo")) self.assertTrue(hasattr(hm, "bar")) self.assertTrue(hasattr(hm, "quux")) -- cgit v1.2.3-1-g7c22