# HG changeset patch
# User paulb
# Date 1105840962 0
# Node ID d03b350b9d4a39d9c7b95a52e81777e934dd445d
# Parent 8b8792612eb43740a652b2eb8f16f578e8f5ecfe
[project @ 2005-01-16 02:02:40 by paulb]
Moved macrotest into the tests directory.
diff -r 8b8792612eb4 -r d03b350b9d4a macrotest.py
--- a/macrotest.py Sun Jan 16 02:00:14 2005 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-#!/usr/bin/env python
-
-"A test of macros."
-
-from libxml2dom.macrolib import *
-import libxml2
-import xml.dom
-
-class Container:
- pass
-
-doc = """
-
-
-
-
-
-"""
-
-def find_root(x2_d):
- x2_root = None
-
- # Property access should be transformed.
-
- for x2_n in x2_d.childNodes:
- if x2_n.nodeType == xml.dom.Node.ELEMENT_NODE:
- x2_root = x2_n
- break
-
- return x2_root
-
-def test():
- global doc
-
- # Assignment should not be transformed.
-
- x2_d = parseString(doc)
- return process(x2_d)
-
-def test_file(filename):
-
- # Assignment should not be transformed.
-
- x2_d = parseFile(filename)
- return process(x2_d)
-
-def process(x2_d):
-
- # Not even within containers, and not special names alone.
-
- c = Container()
- c.x2_d = x2_d
-
- # Find the root element.
-
- x2_root = find_root(x2_d)
- c.x2_root = x2_root
-
- # Create new attributes.
- # Method access should be transformed.
-
- x2_root.setAttributeNS("ns", "xxx:yyy", "zzz")
- c.x2_root.setAttributeNS("ns", "XXX:YYY", "ZZZ")
-
- # Create new elements.
- # Method access should be transformed.
-
- x2_new = x2_d.createElementNS("ns2", "ppp:qqq")
- x2_root.appendChild(x2_new)
- x2_new2 = c.x2_d.createElementNS("ns2", "PPP:QQQ")
- c.x2_root.appendChild(x2_new2)
-
- # Create new elements using ownerDocument.
- # Chaining properties is not
-
- x2_new3 = x2_new.ownerDocument.createElement("fff")
- x2_new.appendChild(x2_new3)
- x2_new4 = x2_new2.ownerDocument.createElement("FFF")
- x2_new2.appendChild(x2_new4)
-
- return x2_d
-
-def test_import(x2_d):
-
- x2_root = find_root(x2_d)
-
- # Create a new document.
-
- x2_d2 = createDocument("nsD", "newdoc", None)
- x2_root2 = find_root(x2_d2)
-
- # Attempt to import nodes from the original document.
-
- x2_imported = x2_d2.importNode(x2_root, 1)
- x2_d2.replaceChild(x2_imported, x2_root2)
-
- return x2_d, x2_d2
-
-# vim: tabstop=4 expandtab shiftwidth=4
diff -r 8b8792612eb4 -r d03b350b9d4a tests/macrotest.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/macrotest.py Sun Jan 16 02:02:42 2005 +0000
@@ -0,0 +1,99 @@
+#!/usr/bin/env python
+
+"A test of macros."
+
+from libxml2dom.macrolib import *
+import libxml2
+import xml.dom
+
+class Container:
+ pass
+
+doc = """
+
+
+
+
+
+"""
+
+def find_root(x2_d):
+ x2_root = None
+
+ # Property access should be transformed.
+
+ for x2_n in x2_d.childNodes:
+ if x2_n.nodeType == xml.dom.Node.ELEMENT_NODE:
+ x2_root = x2_n
+ break
+
+ return x2_root
+
+def test():
+ global doc
+
+ # Assignment should not be transformed.
+
+ x2_d = parseString(doc)
+ return process(x2_d)
+
+def test_file(filename):
+
+ # Assignment should not be transformed.
+
+ x2_d = parseFile(filename)
+ return process(x2_d)
+
+def process(x2_d):
+
+ # Not even within containers, and not special names alone.
+
+ c = Container()
+ c.x2_d = x2_d
+
+ # Find the root element.
+
+ x2_root = find_root(x2_d)
+ c.x2_root = x2_root
+
+ # Create new attributes.
+ # Method access should be transformed.
+
+ x2_root.setAttributeNS("ns", "xxx:yyy", "zzz")
+ c.x2_root.setAttributeNS("ns", "XXX:YYY", "ZZZ")
+
+ # Create new elements.
+ # Method access should be transformed.
+
+ x2_new = x2_d.createElementNS("ns2", "ppp:qqq")
+ x2_root.appendChild(x2_new)
+ x2_new2 = c.x2_d.createElementNS("ns2", "PPP:QQQ")
+ c.x2_root.appendChild(x2_new2)
+
+ # Create new elements using ownerDocument.
+ # Chaining properties is not
+
+ x2_new3 = x2_new.ownerDocument.createElement("fff")
+ x2_new.appendChild(x2_new3)
+ x2_new4 = x2_new2.ownerDocument.createElement("FFF")
+ x2_new2.appendChild(x2_new4)
+
+ return x2_d
+
+def test_import(x2_d):
+
+ x2_root = find_root(x2_d)
+
+ # Create a new document.
+
+ x2_d2 = createDocument("nsD", "newdoc", None)
+ x2_root2 = find_root(x2_d2)
+
+ # Attempt to import nodes from the original document.
+
+ x2_imported = x2_d2.importNode(x2_root, 1)
+ x2_d2.replaceChild(x2_imported, x2_root2)
+
+ return x2_d, x2_d2
+
+# vim: tabstop=4 expandtab shiftwidth=4