From fe716cc6c541239a34d55c0ca5812379a821779a Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Tue, 21 Aug 2012 09:08:14 -0400 Subject: fixed builtin mocks for py3k --- testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py | 4 ++-- testsuite/Testlib/TestServer/TestPlugin.py | 12 ++++++------ testsuite/Testlib/TestServer/TestPlugins/TestMetadata.py | 4 ++-- testsuite/Testlib/TestServer/TestPlugins/TestProbes.py | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) (limited to 'testsuite/Testlib') diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py index 34784dc3d..06912c19c 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py @@ -74,7 +74,7 @@ class TestPOSIXFile(TestPOSIXTool): entry.text = ustr self.assertEqual(ptool._get_data(entry), (ustr, False)) - @patch("__builtin__.open") + @patch("%s.open" % builtins) @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool.verify") @patch("Bcfg2.Client.Tools.POSIX.File.%s._exists" % test_obj.__name__) @patch("Bcfg2.Client.Tools.POSIX.File.%s._get_data" % test_obj.__name__) @@ -207,7 +207,7 @@ class TestPOSIXFile(TestPOSIXTool): mock_rename.assert_called_with(newfile, entry.get("name")) mock_unlink.assert_called_with(newfile) - @patch("__builtin__.open") + @patch("%.open" % builtins) @patch("Bcfg2.Client.Tools.POSIX.File.%s._diff" % test_obj.__name__) @patch("Bcfg2.Client.Tools.POSIX.File.%s._get_data" % test_obj.__name__) @patch("Bcfg2.Client.Tools.POSIX.File.%s._is_string" % test_obj.__name__) diff --git a/testsuite/Testlib/TestServer/TestPlugin.py b/testsuite/Testlib/TestServer/TestPlugin.py index d59b19a32..d1904a2e6 100644 --- a/testsuite/Testlib/TestServer/TestPlugin.py +++ b/testsuite/Testlib/TestServer/TestPlugin.py @@ -227,7 +227,7 @@ class TestThreadedStatistics(TestStatistics): ts = self.get_obj(core) mock_start.assert_any_call() - @patch("__builtin__.open") + @patch("%s.open" % builtins) @patch("Bcfg2.Server.Plugin.ThreadedStatistics.run", Mock()) def test_save(self, mock_open): core = Mock() @@ -270,7 +270,7 @@ class TestThreadedStatistics(TestStatistics): @patch("os.unlink") @patch("os.path.exists") - @patch("__builtin__.open") + @patch("%s.open" % builtins) @patch("lxml.etree.XML") @patch("Bcfg2.Server.Plugin.ThreadedStatistics.run", Mock()) def test_load(self, mock_XML, mock_open, mock_exists, mock_unlink): @@ -444,7 +444,7 @@ class TestFileBacked(Bcfg2TestCase): def get_obj(self, path=datastore, fam=None): return self.test_obj(path, fam=fam) - @patch("__builtin__.open") + @patch("%s.open" % builtins) def test_HandleEvent(self, mock_open): path = "/test" fb = self.get_obj(path) @@ -1349,7 +1349,7 @@ class TestXMLSrc(TestXMLFileBacked): # ensure that the node object has the necessary interface self.assertTrue(hasattr(self.test_obj.__node__, "Match")) - @patch("__builtin__.open") + @patch("%s.open" % builtins) def test_HandleEvent(self, mock_open): xdata = lxml.etree.Element("Test") lxml.etree.SubElement(xdata, "Path", name="path", attr="whatever") @@ -1603,7 +1603,7 @@ class TestSpecificData(Bcfg2TestCase): specific = Mock() return self.test_obj(name, specific, encoding) - @patch("__builtin__.open") + @patch("%s.open" % builtins) def test_handle_event(self, mock_open): event = Mock() event.code2str.return_value = 'deleted' @@ -1912,7 +1912,7 @@ class TestEntrySet(TestDebuggable): fails(eset, ppath + ".G20_") fails(eset, ppath + ".H_") - @patch("__builtin__.open") + @patch("%s.open" % builtins) @patch("Bcfg2.Server.Plugin.InfoXML") def test_update_metadata(self, mock_InfoXML, mock_open): eset = self.get_obj() diff --git a/testsuite/Testlib/TestServer/TestPlugins/TestMetadata.py b/testsuite/Testlib/TestServer/TestPlugins/TestMetadata.py index ee39eb2c9..7382a4439 100644 --- a/testsuite/Testlib/TestServer/TestPlugins/TestMetadata.py +++ b/testsuite/Testlib/TestServer/TestPlugins/TestMetadata.py @@ -274,7 +274,7 @@ class TestXMLMetadataConfig(TestXMLFileBacked): @patch('Bcfg2.Server.Plugins.Metadata.locked', Mock(return_value=False)) @patch('fcntl.lockf', Mock()) - @patch('__builtin__.open') + @patch('%s.open' % builtins) @patch('os.unlink') @patch('os.rename') @patch('os.path.islink') @@ -417,7 +417,7 @@ class TestMetadata(_TestMetadata, TestStatistics, TestDatabaseBacked): self.get_obj, core=core, watch_clients=True) @patch('os.makedirs', Mock()) - @patch('__builtin__.open') + @patch('%s.open' % builtins) def test_init_repo(self, mock_open): Metadata.init_repo(datastore, groups_xml="groups", clients_xml="clients") diff --git a/testsuite/Testlib/TestServer/TestPlugins/TestProbes.py b/testsuite/Testlib/TestServer/TestPlugins/TestProbes.py index 3cff4ac73..a779a7707 100644 --- a/testsuite/Testlib/TestServer/TestPlugins/TestProbes.py +++ b/testsuite/Testlib/TestServer/TestPlugins/TestProbes.py @@ -118,7 +118,7 @@ class TestProbeSet(TestEntrySet): ps.HandleEvent(evt) ps.handle_event.assert_called_with(evt) - @patch("__builtin__.list", FakeList) + @patch("%s.list" % builtins, FakeList) def test_get_probe_data(self): ps = self.get_obj() @@ -268,7 +268,7 @@ text probes._write_data_db.assert_called_with("test") self.assertFalse(probes._write_data_xml.called) - @patch("__builtin__.open") + @patch("%s.open" % builtins) def test__write_data_xml(self, mock_open): probes = self.get_probes_object(use_db=False) probes.probedata = self.get_test_probedata() @@ -394,7 +394,7 @@ text probes._load_data_db.assert_any_call() self.assertFalse(probes._load_data_xml.called) - @patch("__builtin__.open") + @patch("%s.open" % builtins) @patch("lxml.etree.parse") def test__load_data_xml(self, mock_parse, mock_open): probes = self.get_probes_object(use_db=False) -- cgit v1.2.3-1-g7c22