コード例 #1
0
ファイル: test_formatting.py プロジェクト: toyg/xmldiff
    def test_update_text_in(self):
        action = actions.UpdateTextIn("/document/node", "Text")
        expected = '[update-text, /document/node, "Text"]'
        self._format_test(action, expected)

        action = actions.UpdateTextIn("/document/node",
                                      'Also a bit of text, "rick"')
        expected = "[update-text, /document/node, " '"Also a bit of text, \\"rick\\""]'
        self._format_test(action, expected)
コード例 #2
0
ファイル: test_formatting.py プロジェクト: zfl926/xmldiff
    def test_update_text_in(self):
        action = actions.UpdateTextIn('/document/node', 'Text')
        expected = '[update, /document/node/text()[1], "Text"]'
        self._format_test(action, expected)

        action = actions.UpdateTextIn('/document/node',
                                      'Also a bit of text, "rick"')
        expected = '[update, /document/node/text()[1], '\
            u'"Also a bit of text, \\"rick\\""]'
        self._format_test(action, expected)
コード例 #3
0
ファイル: test_formatting.py プロジェクト: toyg/xmldiff
    def test_update_text_in(self):
        left = '<document><node attr="val"/></document>'
        action = actions.UpdateTextIn("/document/node", "Text")
        expected = START + ' attr="val"><diff:insert>Text</diff:insert>' + END

        self._format_test(left, action, expected)

        left = "<document><node>This is a bit of text, right" + END
        action = actions.UpdateTextIn("/document/node",
                                      "Also a bit of text, rick")
        expected = (START + "><diff:delete>This is</diff:delete><diff:insert>"
                    "Also</diff:insert> a bit of text, ri<diff:delete>ght"
                    "</diff:delete><diff:insert>ck</diff:insert>" + END)

        self._format_test(left, action, expected)
コード例 #4
0
ファイル: test_formatting.py プロジェクト: zfl926/xmldiff
    def test_update_text_in(self):
        left = u'<document><node attr="val"/></document>'
        action = actions.UpdateTextIn('/document/node', 'Text')
        expected = START + u' attr="val"><diff:insert>Text</diff:insert>' + END

        self._format_test(left, action, expected)

        left = u'<document><node>This is a bit of text, right' + END
        action = actions.UpdateTextIn('/document/node',
                                      'Also a bit of text, rick')
        expected = START + u'><diff:delete>This is</diff:delete><diff:insert>'\
            u'Also</diff:insert> a bit of text, ri<diff:delete>ght'\
            u'</diff:delete><diff:insert>ck</diff:insert>' + END

        self._format_test(left, action, expected)
コード例 #5
0
    def update_node_text(self, left, right):
        left_xpath = utils.getpath(left)

        if left.text != right.text:
            yield actions.UpdateTextIn(left_xpath, right.text)
            left.text = right.text

        if left.tail != right.tail:
            yield actions.UpdateTextAfter(left_xpath, right.tail)
            left.tail = right.tail
コード例 #6
0
ファイル: test_formatting.py プロジェクト: toyg/xmldiff
 def test_del_text(self):
     action = actions.UpdateTextIn("/document/node", None)
     expected = "[update, /document/node/text()[1], null]"
     self._format_test(action, expected)
コード例 #7
0
ファイル: test_formatting.py プロジェクト: toyg/xmldiff
    def test_del_text(self):
        left = '<document><node attr="val">Text</node></document>'
        action = actions.UpdateTextIn("/document/node", None)
        expected = START + ' attr="val"><diff:delete>Text</diff:delete>' + END

        self._format_test(left, action, expected)
コード例 #8
0
ファイル: patch.py プロジェクト: toyg/xmldiff
 def _handle_update_text(self, node, text):
     return actions.UpdateTextIn(node, loads(text))
コード例 #9
0
ファイル: test_formatting.py プロジェクト: zfl926/xmldiff
 def test_del_text(self):
     action = actions.UpdateTextIn('/document/node', None)
     expected = '[update-text, /document/node, null]'
     self._format_test(action, expected)