Browse Source

Test patch from hg log -p

Matthew Wang 11 years ago
parent
commit
3152b05093
4 changed files with 209 additions and 0 deletions
  1. 53
    0
      tests/hg-log/in.diff
  2. 54
    0
      tests/hg-log/out.normal
  3. 51
    0
      tests/hg-log/out.side-by-side
  4. 51
    0
      tests/hg-log/out.w70

+ 53
- 0
tests/hg-log/in.diff View File

@@ -0,0 +1,53 @@
1
+# HG changeset patch
2
+# User Dan Kenigsberg <danken@redhat.com>
3
+# Date 1317492169 -10800
4
+# Node ID a9a87f0e7c509ec6768379c08a0cf56f43d71b4a
5
+# Parent  b0ef6a5a6dccab0089d287bf6b9bcb8132bdbd0d
6
+xml.dom.minidom toprettyxml: omit whitespace for Text nodes
7
+
8
+http://bugs.python.org/issue4147
9
+
10
+This patch was very lightly tested, but I think it is nicer than the former one,
11
+as Text.writexml() should better know not to wrap its data with whitespace.
12
+Ever.
13
+
14
+diff -r b0ef6a5a6dcc -r a9a87f0e7c50 Lib/test/test_minidom.py
15
+--- a/Lib/test/test_minidom.py	Fri Sep 30 08:46:25 2011 +0300
16
++++ b/Lib/test/test_minidom.py	Sat Oct 01 21:02:49 2011 +0300
17
+@@ -467,6 +467,13 @@
18
+         dom.unlink()
19
+         self.confirm(domstr == str.replace("\n", "\r\n"))
20
+ 
21
++    def testPrettyTextNode(self):
22
++        str = '<A>B</A>'
23
++        dom = parseString(str)
24
++        dom2 = parseString(dom.toprettyxml())
25
++        self.confirm(dom.childNodes[0].childNodes[0].toxml()==
26
++                     dom2.childNodes[0].childNodes[0].toxml())
27
++
28
+     def testProcessingInstruction(self):
29
+         dom = parseString('<e><?mypi \t\n data \t\n ?></e>')
30
+         pi = dom.documentElement.firstChild
31
+diff -r b0ef6a5a6dcc -r a9a87f0e7c50 Lib/xml/dom/minidom.py
32
+--- a/Lib/xml/dom/minidom.py	Fri Sep 30 08:46:25 2011 +0300
33
++++ b/Lib/xml/dom/minidom.py	Sat Oct 01 21:02:49 2011 +0300
34
+@@ -836,7 +836,9 @@
35
+             _write_data(writer, attrs[a_name].value)
36
+             writer.write("\"")
37
+         if self.childNodes:
38
+-            writer.write(">%s"%(newl))
39
++            writer.write(">")
40
++            if self.childNodes[0].nodeType != Node.TEXT_NODE:
41
++                writer.write(newl)
42
+             for node in self.childNodes:
43
+                 node.writexml(writer,indent+addindent,addindent,newl)
44
+             writer.write("%s</%s>%s" % (indent,self.tagName,newl))
45
+@@ -1061,7 +1063,7 @@
46
+         return newText
47
+ 
48
+     def writexml(self, writer, indent="", addindent="", newl=""):
49
+-        _write_data(writer, "%s%s%s"%(indent, self.data, newl))
50
++        _write_data(writer, self.data)
51
+ 
52
+     # DOM Level 3 (WD 9 April 2002)
53
+ 

+ 54
- 0
tests/hg-log/out.normal View File

@@ -0,0 +1,54 @@
1
+# HG changeset patch
2
+# User Dan Kenigsberg <danken@redhat.com>
3
+# Date 1317492169 -10800
4
+# Node ID a9a87f0e7c509ec6768379c08a0cf56f43d71b4a
5
+# Parent  b0ef6a5a6dccab0089d287bf6b9bcb8132bdbd0d
6
+xml.dom.minidom toprettyxml: omit whitespace for Text nodes
7
+
8
+http://bugs.python.org/issue4147
9
+
10
+This patch was very lightly tested, but I think it is nicer than the former one,
11
+as Text.writexml() should better know not to wrap its data with whitespace.
12
+Ever.
13
+
14
+diff -r b0ef6a5a6dcc -r a9a87f0e7c50 Lib/test/test_minidom.py
15
+--- a/Lib/test/test_minidom.py	Fri Sep 30 08:46:25 2011 +0300
16
++++ b/Lib/test/test_minidom.py	Sat Oct 01 21:02:49 2011 +0300
17
+@@ -467,6 +467,13 @@
18
+         dom.unlink()
19
+         self.confirm(domstr == str.replace("\n", "\r\n"))
20
++
21
++    def testPrettyTextNode(self):
22
++        str = '<A>B</A>'
23
++        dom = parseString(str)
24
++        dom2 = parseString(dom.toprettyxml())
25
++        self.confirm(dom.childNodes[0].childNodes[0].toxml()==
26
++                     dom2.childNodes[0].childNodes[0].toxml())
27
+ 
28
+     def testProcessingInstruction(self):
29
+         dom = parseString('<e><?mypi \t\n data \t\n ?></e>')
30
+         pi = dom.documentElement.firstChild
31
+diff -r b0ef6a5a6dcc -r a9a87f0e7c50 Lib/xml/dom/minidom.py
32
+--- a/Lib/xml/dom/minidom.py	Fri Sep 30 08:46:25 2011 +0300
33
++++ b/Lib/xml/dom/minidom.py	Sat Oct 01 21:02:49 2011 +0300
34
+@@ -836,7 +836,9 @@
35
+             _write_data(writer, attrs[a_name].value)
36
+             writer.write("\"")
37
+         if self.childNodes:
38
+-            writer.write(">%s"%(newl))
39
++            writer.write(">")
40
++            if self.childNodes[0].nodeType != Node.TEXT_NODE:
41
++                writer.write(newl)
42
+             for node in self.childNodes:
43
+                 node.writexml(writer,indent+addindent,addindent,newl)
44
+             writer.write("%s</%s>%s" % (indent,self.tagName,newl))
45
+@@ -1061,7 +1063,7 @@
46
+         return newText
47
+ 
48
+     def writexml(self, writer, indent="", addindent="", newl=""):
49
+-        _write_data(writer, "%s%s%s"%(indent, self.data, newl))
50
++        _write_data(writer, self.data)
51
+ 
52
+     # DOM Level 3 (WD 9 April 2002)
53
+ 
54
+

+ 51
- 0
tests/hg-log/out.side-by-side View File

@@ -0,0 +1,51 @@
1
+# HG changeset patch
2
+# User Dan Kenigsberg <danken@redhat.com>
3
+# Date 1317492169 -10800
4
+# Node ID a9a87f0e7c509ec6768379c08a0cf56f43d71b4a
5
+# Parent  b0ef6a5a6dccab0089d287bf6b9bcb8132bdbd0d
6
+xml.dom.minidom toprettyxml: omit whitespace for Text nodes
7
+
8
+http://bugs.python.org/issue4147
9
+
10
+This patch was very lightly tested, but I think it is nicer than the former one,
11
+as Text.writexml() should better know not to wrap its data with whitespace.
12
+Ever.
13
+
14
+diff -r b0ef6a5a6dcc -r a9a87f0e7c50 Lib/test/test_minidom.py
15
+--- a/Lib/test/test_minidom.py	Fri Sep 30 08:46:25 2011 +0300
16
++++ b/Lib/test/test_minidom.py	Sat Oct 01 21:02:49 2011 +0300
17
+@@ -467,6 +467,13 @@
18
+467         dom.unlink()                                                             467         dom.unlink()
19
+468         self.confirm(domstr == str.replace("\n", "\r\n"))                        468         self.confirm(domstr == str.replace("\n", "\r\n"))
20
+                                                                                     469 
21
+                                                                                     470     def testPrettyTextNode(self):
22
+                                                                                     471         str = '<A>B</A>'
23
+                                                                                     472         dom = parseString(str)
24
+                                                                                     473         dom2 = parseString(dom.toprettyxml())
25
+                                                                                     474         self.confirm(dom.childNodes[0].childNodes[0].toxml()==
26
+                                                                                     475                      dom2.childNodes[0].childNodes[0].toxml())
27
+469                                                                                  476 
28
+470     def testProcessingInstruction(self):                                         477     def testProcessingInstruction(self):
29
+471         dom = parseString('<e><?mypi \t\n data \t\n ?></e>')                     478         dom = parseString('<e><?mypi \t\n data \t\n ?></e>')
30
+472         pi = dom.documentElement.firstChild                                      479         pi = dom.documentElement.firstChild
31
+diff -r b0ef6a5a6dcc -r a9a87f0e7c50 Lib/xml/dom/minidom.py
32
+--- a/Lib/xml/dom/minidom.py	Fri Sep 30 08:46:25 2011 +0300
33
++++ b/Lib/xml/dom/minidom.py	Sat Oct 01 21:02:49 2011 +0300
34
+@@ -836,7 +836,9 @@
35
+ 836             _write_data(writer, attrs[a_name].value)                              836             _write_data(writer, attrs[a_name].value)
36
+ 837             writer.write("\"")                                                    837             writer.write("\"")
37
+ 838         if self.childNodes:                                                       838         if self.childNodes:
38
+ 839             writer.write(">%s"%(newl))                                            839             writer.write(">")
39
+                                                                                       840             if self.childNodes[0].nodeType != Node.TEXT_NODE:
40
+                                                                                       841                 writer.write(newl)
41
+ 840             for node in self.childNodes:                                          842             for node in self.childNodes:
42
+ 841                 node.writexml(writer,indent+addindent,addindent,newl)             843                 node.writexml(writer,indent+addindent,addindent,newl)
43
+ 842             writer.write("%s</%s>%s" % (indent,self.tagName,newl))                844             writer.write("%s</%s>%s" % (indent,self.tagName,newl))
44
+@@ -1061,7 +1063,7 @@
45
+1061         return newText                                                           1063         return newText
46
+1062                                                                                  1064 
47
+1063     def writexml(self, writer, indent="", addindent="", newl=""):                1065     def writexml(self, writer, indent="", addindent="", newl=""):
48
+1064         _write_data(writer, "%s%s%s"%(indent, self.data, newl))                  1066         _write_data(writer, self.data)
49
+1065                                                                                  1067 
50
+1066     # DOM Level 3 (WD 9 April 2002)                                              1068     # DOM Level 3 (WD 9 April 2002)
51
+1067                                                                                  1069 

+ 51
- 0
tests/hg-log/out.w70 View File

@@ -0,0 +1,51 @@
1
+# HG changeset patch
2
+# User Dan Kenigsberg <danken@redhat.com>
3
+# Date 1317492169 -10800
4
+# Node ID a9a87f0e7c509ec6768379c08a0cf56f43d71b4a
5
+# Parent  b0ef6a5a6dccab0089d287bf6b9bcb8132bdbd0d
6
+xml.dom.minidom toprettyxml: omit whitespace for Text nodes
7
+
8
+http://bugs.python.org/issue4147
9
+
10
+This patch was very lightly tested, but I think it is nicer than the former one,
11
+as Text.writexml() should better know not to wrap its data with whitespace.
12
+Ever.
13
+
14
+diff -r b0ef6a5a6dcc -r a9a87f0e7c50 Lib/test/test_minidom.py
15
+--- a/Lib/test/test_minidom.py	Fri Sep 30 08:46:25 2011 +0300
16
++++ b/Lib/test/test_minidom.py	Sat Oct 01 21:02:49 2011 +0300
17
+@@ -467,6 +467,13 @@
18
+467         dom.unlink()                                                   467         dom.unlink()
19
+468         self.confirm(domstr == str.replace("\n", "\r\n"))              468         self.confirm(domstr == str.replace("\n", "\r\n"))
20
+                                                                           469 
21
+                                                                           470     def testPrettyTextNode(self):
22
+                                                                           471         str = '<A>B</A>'
23
+                                                                           472         dom = parseString(str)
24
+                                                                           473         dom2 = parseString(dom.toprettyxml())
25
+                                                                           474         self.confirm(dom.childNodes[0].childNodes[0].toxml()==
26
+                                                                           475                      dom2.childNodes[0].childNodes[0].toxml())
27
+469                                                                        476 
28
+470     def testProcessingInstruction(self):                               477     def testProcessingInstruction(self):
29
+471         dom = parseString('<e><?mypi \t\n data \t\n ?></e>')           478         dom = parseString('<e><?mypi \t\n data \t\n ?></e>')
30
+472         pi = dom.documentElement.firstChild                            479         pi = dom.documentElement.firstChild
31
+diff -r b0ef6a5a6dcc -r a9a87f0e7c50 Lib/xml/dom/minidom.py
32
+--- a/Lib/xml/dom/minidom.py	Fri Sep 30 08:46:25 2011 +0300
33
++++ b/Lib/xml/dom/minidom.py	Sat Oct 01 21:02:49 2011 +0300
34
+@@ -836,7 +836,9 @@
35
+ 836             _write_data(writer, attrs[a_name].value)                    836             _write_data(writer, attrs[a_name].value)
36
+ 837             writer.write("\"")                                          837             writer.write("\"")
37
+ 838         if self.childNodes:                                             838         if self.childNodes:
38
+ 839             writer.write(">%s"%(newl))                                  839             writer.write(">")
39
+                                                                             840             if self.childNodes[0].nodeType != Node.TEXT_NODE:
40
+                                                                             841                 writer.write(newl)
41
+ 840             for node in self.childNodes:                                842             for node in self.childNodes:
42
+ 841                 node.writexml(writer,indent+addindent,addindent,newl)   843                 node.writexml(writer,indent+addindent,addindent,newl)
43
+ 842             writer.write("%s</%s>%s" % (indent,self.tagName,newl))      844             writer.write("%s</%s>%s" % (indent,self.tagName,newl))
44
+@@ -1061,7 +1063,7 @@
45
+1061         return newText                                                 1063         return newText
46
+1062                                                                        1064 
47
+1063     def writexml(self, writer, indent="", addindent="", newl=""):      1065     def writexml(self, writer, indent="", addindent="", newl=""):
48
+1064         _write_data(writer, "%s%s%s"%(indent, self.data, newl))        1066         _write_data(writer, self.data)
49
+1065                                                                        1067 
50
+1066     # DOM Level 3 (WD 9 April 2002)                                    1068     # DOM Level 3 (WD 9 April 2002)
51
+1067                                                                        1069