def test_all_actions(self): here = os.path.split(__file__)[0] lfile = os.path.join(here, "test_data", "all_actions.left.xml") rfile = os.path.join(here, "test_data", "all_actions.right.xml") formatter = formatting.XmlDiffFormatter() result = main.diff_files(lfile, rfile, formatter=formatter) expected = ( "[move-after, /document/node[2], /document/tag[1]]\n" "[insert-comment, /document[1], 0, Insert a new comment ]\n" '[update, /document/node[1]/@name, "was updated"]\n' "[remove, /document/node[1]/@attribute]\n" "[insert, /document/node[1], \n" "<@newtribute>\n" "renamed\n" "</@newtribute>]\n" "[insert, /document/node[1], \n" "<@this>\n" "is new\n" "</@this>]\n" "[remove, /document/node[1]/@attr]\n" '[update, /document/node[1]/text()[1], "\\n Modified\\n "]\n' '[update, /document/node[1]/text()[2], "\\n ' 'New tail content\\n "]\n' "[rename, /document/node[2], nod]\n" "[insert-after, /document/tail[1], \n" "<new/>]\n" "[remove, /document/tail[1]]") self.assertEqual(result, expected)
def _format_test(self, action, expected): formatter = formatting.XmlDiffFormatter() result = formatter.format([action], None) self.assertEqual(result, expected)