diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-08-21 13:32:51 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-08-21 13:33:20 -0400 |
commit | 22016ee593d6047855964734a17120d2aea6b5a5 (patch) | |
tree | 92adbca098e89295d4217561ee53454134b781a2 /testsuite/Testlib | |
parent | d6bf20100848dc61b971844e21d24da44b9f65f7 (diff) | |
download | bcfg2-22016ee593d6047855964734a17120d2aea6b5a5.tar.gz bcfg2-22016ee593d6047855964734a17120d2aea6b5a5.tar.bz2 bcfg2-22016ee593d6047855964734a17120d2aea6b5a5.zip |
lots of various py3k fixes
Diffstat (limited to 'testsuite/Testlib')
10 files changed, 112 insertions, 110 deletions
diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDevice.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDevice.py index f32da9c37..b737cfe1e 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDevice.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDevice.py @@ -4,8 +4,8 @@ import unittest import lxml.etree from mock import Mock, MagicMock, patch from Bcfg2.Client.Tools.POSIX.Device import * -from Test__init import get_posix_object -from Testbase import TestPOSIXTool +from .Test__init import get_posix_object +from .Testbase import TestPOSIXTool from .....common import * class TestPOSIXDevice(TestPOSIXTool): @@ -97,8 +97,8 @@ class TestPOSIXDevice(TestPOSIXTool): self.assertTrue(ptool.install(entry)) mock_exists.assert_called_with(entry, remove=True) mock_makedev.assert_called_with(0, 10) - mock_mknod.assert_called_with(entry.get("name"), - device_map[entry.get("dev_type")] | 0644, + mock_mknod.assert_called_with(entry.get("name"), # 0o644 + device_map[entry.get("dev_type")] | 420, mock_makedev.return_value) mock_install.assert_called_with(ptool, entry) @@ -127,6 +127,6 @@ class TestPOSIXDevice(TestPOSIXTool): self.assertTrue(ptool.install(entry)) mock_exists.assert_called_with(entry, remove=True) - mock_mknod.assert_called_with(entry.get("name"), - device_map[entry.get("dev_type")] | 0644) + mock_mknod.assert_called_with(entry.get("name"), # 0o644 + device_map[entry.get("dev_type")] | 420) mock_install.assert_called_with(ptool, entry) diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDirectory.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDirectory.py index 34c98fa9c..79879afed 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDirectory.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDirectory.py @@ -5,8 +5,8 @@ import unittest import lxml.etree from mock import Mock, MagicMock, patch from Bcfg2.Client.Tools.POSIX.Directory import * -from Test__init import get_posix_object -from Testbase import TestPOSIXTool +from .Test__init import get_posix_object +from .Testbase import TestPOSIXTool from .....common import * class TestPOSIXDirectory(TestPOSIXTool): @@ -25,14 +25,14 @@ class TestPOSIXDirectory(TestPOSIXTool): mock_exists.reset_mock() exists_rv = MagicMock() - exists_rv.__getitem__.return_value = stat.S_IFREG | 0644 + exists_rv.__getitem__.return_value = stat.S_IFREG | 420 # 0o644 mock_exists.return_value = exists_rv self.assertFalse(ptool.verify(entry, [])) mock_exists.assert_called_with(entry) mock_exists.reset_mock() mock_verify.return_value = False - exists_rv.__getitem__.return_value = stat.S_IFDIR | 0644 + exists_rv.__getitem__.return_value = stat.S_IFDIR | 420 # 0o644 self.assertFalse(ptool.verify(entry, [])) mock_exists.assert_called_with(entry) mock_verify.assert_called_with(ptool, entry, []) @@ -105,7 +105,7 @@ class TestPOSIXDirectory(TestPOSIXTool): reset() exists_rv = MagicMock() - exists_rv.__getitem__.return_value = stat.S_IFREG | 0644 + exists_rv.__getitem__.return_value = stat.S_IFREG | 420 # 0o644 mock_exists.return_value = exists_rv self.assertTrue(ptool.install(entry)) mock_unlink.assert_called_with(entry.get("name")) @@ -114,7 +114,7 @@ class TestPOSIXDirectory(TestPOSIXTool): mock_install.assert_called_with(ptool, entry) reset() - exists_rv.__getitem__.return_value = stat.S_IFDIR | 0644 + exists_rv.__getitem__.return_value = stat.S_IFDIR | 420 # 0o644 mock_install.return_value = True self.assertTrue(ptool.install(entry)) mock_exists.assert_called_with(entry) diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py index 06912c19c..084268959 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py @@ -5,10 +5,11 @@ import difflib import binascii import unittest import lxml.etree +from Bcfg2.Bcfg2Py3k import b64encode, b64decode from mock import Mock, MagicMock, patch from Bcfg2.Client.Tools.POSIX.File import * -from Test__init import get_posix_object -from Testbase import TestPOSIXTool +from .Test__init import get_posix_object +from .Testbase import TestPOSIXTool from .....common import * def get_file_object(posix=None): @@ -33,17 +34,18 @@ class TestPOSIXFile(TestPOSIXTool): def test_is_string(self): ptool = self.get_obj() - for char in range(8) + range(14, 32): + for char in list(range(8)) + list(range(14, 32)): self.assertFalse(ptool._is_string("foo" + chr(char) + "bar", - 'utf_8')) - for char in range(9, 14) + range(33, 128): + 'UTF-8')) + for char in list(range(9, 14)) + list(range(33, 128)): self.assertTrue(ptool._is_string("foo" + chr(char) + "bar", - 'utf_8')) - self.assertFalse(ptool._is_string("foo" + chr(128) + "bar", - 'ascii')) + 'UTF-8')) ustr = 'é' - self.assertTrue(ptool._is_string(ustr, 'utf_8')) - self.assertFalse(ptool._is_string(ustr, 'ascii')) + self.assertTrue(ptool._is_string(ustr, 'UTF-8')) + if not inPy3k: + self.assertFalse(ptool._is_string("foo" + chr(128) + "bar", + 'ascii')) + self.assertFalse(ptool._is_string(ustr, 'ascii')) def test_get_data(self): orig_entry = lxml.etree.Element("Path", name="/test", type="file") @@ -51,7 +53,7 @@ class TestPOSIXFile(TestPOSIXTool): ptool = self.get_obj(posix=get_posix_object(setup=setup)) entry = copy.deepcopy(orig_entry) - entry.text = binascii.b2a_base64("test") + entry.text = b64encode("test") entry.set("encoding", "base64") self.assertEqual(ptool._get_data(entry), ("test", True)) @@ -63,7 +65,7 @@ class TestPOSIXFile(TestPOSIXTool): entry.text = "test" self.assertEqual(ptool._get_data(entry), ("test", False)) - ustr = u'é' + ustr = u('é') entry = copy.deepcopy(orig_entry) entry.text = ustr self.assertEqual(ptool._get_data(entry), (ustr, False)) @@ -207,7 +209,7 @@ class TestPOSIXFile(TestPOSIXTool): mock_rename.assert_called_with(newfile, entry.get("name")) mock_unlink.assert_called_with(newfile) - @patch("%.open" % builtins) + @patch("%s.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__) @@ -239,8 +241,7 @@ class TestPOSIXFile(TestPOSIXTool): mock_open.assert_called_with(entry.get("name")) mock_open.return_value.read.assert_any_call() self.assertFalse(mock_diff.called) - self.assertEqual(entry.get("current_bfile"), - binascii.b2a_base64(ondisk)) + self.assertEqual(entry.get("current_bfile"), b64encode(ondisk)) # binary data on disk entry = reset() @@ -248,8 +249,7 @@ class TestPOSIXFile(TestPOSIXTool): ptool._get_diffs(entry, content=ondisk) self.assertFalse(mock_open.called) self.assertFalse(mock_diff.called) - self.assertEqual(entry.get("current_bfile"), - binascii.b2a_base64(ondisk)) + self.assertEqual(entry.get("current_bfile"), b64encode(ondisk)) # sensitive, non-interactive -- do nothing entry = reset() @@ -278,7 +278,7 @@ class TestPOSIXFile(TestPOSIXTool): filename=entry.get("name")) self.assertIsNone(entry.get("qtext")) self.assertEqual(entry.get("current_bdiff"), - binascii.b2a_base64("\n".join(mock_diff.return_value))) + b64encode("\n".join(mock_diff.return_value))) del entry.attrib["current_bdiff"] self.assertItemsEqual(orig_entry.attrib, entry.attrib) @@ -297,14 +297,14 @@ class TestPOSIXFile(TestPOSIXTool): self.assertIsNotNone(entry.get("qtext")) self.assertTrue(entry.get("qtext").startswith("test\n")) self.assertEqual(entry.get("current_bdiff"), - binascii.b2a_base64("\n".join(mock_diff.return_value))) + b64encode("\n".join(mock_diff.return_value))) del entry.attrib['qtext'] del entry.attrib["current_bdiff"] self.assertItemsEqual(orig_entry.attrib, entry.attrib) # non-sensitive, interactive with unicode data entry = reset() - entry.text = u"tëst" + entry.text = u("tëst") encoded = entry.text.encode(setup['encoding']) mock_get_data.return_value = (encoded, False) ptool._get_diffs(entry, interactive=True) @@ -317,7 +317,7 @@ class TestPOSIXFile(TestPOSIXTool): filename=entry.get("name"))]) self.assertIsNotNone(entry.get("qtext")) self.assertEqual(entry.get("current_bdiff"), - binascii.b2a_base64("\n".join(mock_diff.return_value))) + b64encode("\n".join(mock_diff.return_value))) del entry.attrib['qtext'] del entry.attrib["current_bdiff"] self.assertItemsEqual(orig_entry.attrib, entry.attrib) diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestHardlink.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestHardlink.py index 663c98af2..221da9ea5 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestHardlink.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestHardlink.py @@ -4,8 +4,8 @@ import unittest import lxml.etree from mock import Mock, MagicMock, patch from Bcfg2.Client.Tools.POSIX.Hardlink import * -from Test__init import get_posix_object -from Testbase import TestPOSIXTool +from .Test__init import get_posix_object +from .Testbase import TestPOSIXTool from .....common import * class TestPOSIXHardlink(TestPOSIXTool): diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestNonexistent.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestNonexistent.py index 8d959a15f..2b46bd9e6 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestNonexistent.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestNonexistent.py @@ -4,8 +4,8 @@ import unittest import lxml.etree from mock import Mock, MagicMock, patch from Bcfg2.Client.Tools.POSIX.Nonexistent import * -from Test__init import get_config, get_posix_object -from Testbase import TestPOSIXTool +from .Test__init import get_config, get_posix_object +from .Testbase import TestPOSIXTool from .....common import * class TestPOSIXNonexistent(TestPOSIXTool): diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestPermissions.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestPermissions.py index 9d8130658..008f0c839 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestPermissions.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestPermissions.py @@ -3,8 +3,8 @@ import unittest import lxml.etree from mock import Mock, MagicMock, patch from Bcfg2.Client.Tools.POSIX.Permissions import * -from Test__init import get_posix_object -from Testbase import TestPOSIXTool +from .Test__init import get_posix_object +from .Testbase import TestPOSIXTool from .....common import * class TestPOSIXPermissions(TestPOSIXTool): diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py index 03504ca61..7ce8a4437 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py @@ -4,8 +4,8 @@ import unittest import lxml.etree from mock import Mock, MagicMock, patch from Bcfg2.Client.Tools.POSIX.Symlink import * -from Test__init import get_posix_object -from Testbase import TestPOSIXTool +from .Test__init import get_posix_object +from .Testbase import TestPOSIXTool from .....common import * class TestPOSIXSymlink(TestPOSIXTool): diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/Testbase.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/Testbase.py index 442641c0b..e8e5dbe23 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/Testbase.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/Testbase.py @@ -6,7 +6,7 @@ import lxml.etree from mock import Mock, MagicMock, patch import Bcfg2.Client.Tools from Bcfg2.Client.Tools.POSIX.base import * -from Test__init import get_posix_object +from .Test__init import get_posix_object from .....common import * try: @@ -240,13 +240,13 @@ class TestPOSIXTool(Bcfg2TestCase): raise KeyError os.chown.side_effect = chown_rv entry.set("type", "device") - entry.set("dev_type", device_map.keys()[0]) + entry.set("dev_type", list(device_map.keys())[0]) self.assertFalse(ptool._set_perms(entry)) mock_norm_uid.assert_called_with(entry) mock_norm_gid.assert_called_with(entry) mock_chown.assert_called_with(entry.get("name"), 0, 0) mock_chmod.assert_called_with(entry.get("name"), - int(entry.get("perms"), 8) | device_map.values()[0]) + int(entry.get("perms"), 8) | list(device_map.values())[0]) mock_utime.assert_called_with(entry.get("name"), (mtime, mtime)) mock_set_secontext.assert_called_with(entry, path=entry.get("name")) mock_set_acls.assert_called_with(entry, path=entry.get("name")) diff --git a/testsuite/Testlib/TestServer/TestPlugin.py b/testsuite/Testlib/TestServer/TestPlugin.py index d1904a2e6..c00a7d91d 100644 --- a/testsuite/Testlib/TestServer/TestPlugin.py +++ b/testsuite/Testlib/TestServer/TestPlugin.py @@ -4,9 +4,10 @@ import copy import logging import unittest import lxml.etree +import Bcfg2.Server +from Bcfg2.Bcfg2Py3k import reduce from mock import Mock, MagicMock, patch from Bcfg2.Server.Plugin import * -import Bcfg2.Server from ...common import * class FakeElementTree(lxml.etree._ElementTree): @@ -228,8 +229,9 @@ class TestThreadedStatistics(TestStatistics): mock_start.assert_any_call() @patch("%s.open" % builtins) + @patch("%s.dump" % cPickle.__name__) @patch("Bcfg2.Server.Plugin.ThreadedStatistics.run", Mock()) - def test_save(self, mock_open): + def test_save(self, mock_dump, mock_open): core = Mock() ts = self.get_obj(core) queue = Mock() @@ -255,78 +257,76 @@ class TestThreadedStatistics(TestStatistics): queue.get_nowait = Mock(side_effect=lambda: queue.data.pop()) mock_open.side_effect = None - # oh, the joy of working around different package names in - # py3k... - with patch("%s.dump" % cPickle.__name__) as mock_dump: - ts.save() - queue.empty.assert_any_call() - queue.get_nowait.assert_any_call() - mock_open.assert_called_with(ts.pending_file, 'w') - mock_open.return_value.close.assert_any_call() - # the order of the queue data gets changed, so we have to - # verify this call in an ugly way - self.assertItemsEqual(mock_dump.call_args[0][0], self.data) - self.assertEqual(mock_dump.call_args[0][1], mock_open.return_value) + ts.save() + queue.empty.assert_any_call() + queue.get_nowait.assert_any_call() + mock_open.assert_called_with(ts.pending_file, 'w') + mock_open.return_value.close.assert_any_call() + # the order of the queue data gets changed, so we have to + # verify this call in an ugly way + self.assertItemsEqual(mock_dump.call_args[0][0], self.data) + self.assertEqual(mock_dump.call_args[0][1], mock_open.return_value) @patch("os.unlink") @patch("os.path.exists") @patch("%s.open" % builtins) @patch("lxml.etree.XML") + @patch("%s.load" % cPickle.__name__) @patch("Bcfg2.Server.Plugin.ThreadedStatistics.run", Mock()) - def test_load(self, mock_XML, mock_open, mock_exists, mock_unlink): + def test_load(self, mock_load, mock_XML, mock_open, mock_exists, + mock_unlink): core = Mock() core.terminate.isSet.return_value = False ts = self.get_obj(core) - with patch("%s.load" % cPickle.__name__) as mock_load: - ts.work_queue = Mock() + ts.work_queue = Mock() + ts.work_queue.data = [] + def reset(): + core.reset_mock() + mock_open.reset_mock() + mock_exists.reset_mock() + mock_unlink.reset_mock() + mock_load.reset_mock() + mock_XML.reset_mock() + ts.work_queue.reset_mock() ts.work_queue.data = [] - def reset(): - core.reset_mock() - mock_open.reset_mock() - mock_exists.reset_mock() - mock_unlink.reset_mock() - mock_load.reset_mock() - mock_XML.reset_mock() - ts.work_queue.reset_mock() - ts.work_queue.data = [] - - mock_exists.return_value = False - self.assertTrue(ts.load()) - mock_exists.assert_called_with(ts.pending_file) - reset() - mock_exists.return_value = True - mock_open.side_effect = OSError - self.assertFalse(ts.load()) - mock_exists.assert_called_with(ts.pending_file) - mock_open.assert_called_with(ts.pending_file, 'r') + mock_exists.return_value = False + self.assertTrue(ts.load()) + mock_exists.assert_called_with(ts.pending_file) - reset() - mock_open.side_effect = None - mock_load.return_value = self.data - ts.work_queue.put_nowait.side_effect = Full - self.assertTrue(ts.load()) - mock_exists.assert_called_with(ts.pending_file) - mock_open.assert_called_with(ts.pending_file, 'r') - mock_open.return_value.close.assert_any_call() - mock_load.assert_called_with(mock_open.return_value) + reset() + mock_exists.return_value = True + mock_open.side_effect = OSError + self.assertFalse(ts.load()) + mock_exists.assert_called_with(ts.pending_file) + mock_open.assert_called_with(ts.pending_file, 'r') - reset() - core.build_metadata.side_effect = lambda x: x - mock_XML.side_effect = lambda x, parser=None: x - ts.work_queue.put_nowait.side_effect = None - self.assertTrue(ts.load()) - mock_exists.assert_called_with(ts.pending_file) - mock_open.assert_called_with(ts.pending_file, 'r') - mock_open.return_value.close.assert_any_call() - mock_load.assert_called_with(mock_open.return_value) - self.assertItemsEqual(mock_XML.call_args_list, - [call(x, parser=Bcfg2.Server.XMLParser) - for h, x in self.data]) - self.assertItemsEqual(ts.work_queue.put_nowait.call_args_list, - [call((h, x)) for h, x in self.data]) - mock_unlink.assert_called_with(ts.pending_file) + reset() + mock_open.side_effect = None + mock_load.return_value = self.data + ts.work_queue.put_nowait.side_effect = Full + self.assertTrue(ts.load()) + mock_exists.assert_called_with(ts.pending_file) + mock_open.assert_called_with(ts.pending_file, 'r') + mock_open.return_value.close.assert_any_call() + mock_load.assert_called_with(mock_open.return_value) + + reset() + core.build_metadata.side_effect = lambda x: x + mock_XML.side_effect = lambda x, parser=None: x + ts.work_queue.put_nowait.side_effect = None + self.assertTrue(ts.load()) + mock_exists.assert_called_with(ts.pending_file) + mock_open.assert_called_with(ts.pending_file, 'r') + mock_open.return_value.close.assert_any_call() + mock_load.assert_called_with(mock_open.return_value) + self.assertItemsEqual(mock_XML.call_args_list, + [call(x, parser=Bcfg2.Server.XMLParser) + for h, x in self.data]) + self.assertItemsEqual(ts.work_queue.put_nowait.call_args_list, + [call((h, x)) for h, x in self.data]) + mock_unlink.assert_called_with(ts.pending_file) @patch("threading.Thread.start", Mock()) @patch("Bcfg2.Server.Plugin.ThreadedStatistics.load") @@ -1018,7 +1018,7 @@ class TestStructFile(TestXMLFileBacked): mock_match.side_effect = match_rv actual = sf.Match(metadata) expected = reduce(lambda x, y: x + y, - children.values() + subgroups.values()) + list(children.values()) + list(subgroups.values())) self.assertEqual(len(actual), len(expected)) # easiest way to compare the values is actually to make # them into an XML document and let assertXMLEqual compare @@ -1047,7 +1047,7 @@ class TestStructFile(TestXMLFileBacked): expected = lxml.etree.Element(xdata.tag, **xdata.attrib) expected.text = xdata.text expected.extend(reduce(lambda x, y: x + y, - children.values() + subchildren.values())) + list(children.values()) + list(subchildren.values()))) expected.extend(standalone) self.assertXMLEqual(actual, expected) @@ -1064,7 +1064,7 @@ class TestStructFile(TestXMLFileBacked): for call in mock_xml_match.call_args_list: actual.append(call[0][0]) self.assertEqual(call[0][1], metadata) - expected = groups.values() + standalone + expected = list(groups.values()) + standalone # easiest way to compare the values is actually to make # them into an XML document and let assertXMLEqual compare # them diff --git a/testsuite/Testlib/TestServer/TestPlugins/TestProbes.py b/testsuite/Testlib/TestServer/TestPlugins/TestProbes.py index a779a7707..df9248e50 100644 --- a/testsuite/Testlib/TestServer/TestPlugins/TestProbes.py +++ b/testsuite/Testlib/TestServer/TestPlugins/TestProbes.py @@ -53,7 +53,7 @@ class TestProbeData(Bcfg2TestCase): def test_xdata(self): xdata = lxml.etree.Element("test") lxml.etree.SubElement(xdata, "test2") - data = ProbeData(lxml.etree.tostring(xdata)) + data = ProbeData(lxml.etree.tostring(xdata, encoding='unicode')) self.assertIsNotNone(data.xdata) self.assertIsNotNone(data.xdata.find("test2")) @@ -193,7 +193,7 @@ class TestProbes(TestProbing, TestConnector, TestDatabaseBacked): rv = dict() rv["foo.example.com"] = ClientProbeDataSet(timestamp=time.time()) rv["foo.example.com"]["xml"] = \ - ProbeData(lxml.etree.tostring(test_xdata)) + ProbeData(lxml.etree.tostring(test_xdata, encoding='unicode')) rv["foo.example.com"]["text"] = ProbeData("freeform text") rv["foo.example.com"]["multiline"] = ProbeData("""multiple lines @@ -277,7 +277,8 @@ text mock_open.assert_called_with(os.path.join(datastore, probes.name, "probed.xml"), "w") - data = lxml.etree.XML(str(mock_open.return_value.write.call_args[0][0])) + print("data=%s" % mock_open.return_value.write.call_args[0][0]) + data = lxml.etree.XML(mock_open.return_value.write.call_args[0][0]) self.assertEqual(len(data.xpath("//Client")), 2) foodata = data.find("Client[@name='foo.example.com']") @@ -290,6 +291,7 @@ text xml = foodata.find("Probe[@name='xml']") self.assertIsNotNone(xml) self.assertIsNotNone(xml.get("value")) + print("value=%s" % xml.get("value")) xdata = lxml.etree.XML(xml.get("value")) self.assertIsNotNone(xdata) self.assertIsNotNone(xdata.find("test")) |