]> granicus.if.org Git - python/commitdiff
Integrate the tests for name interning from PyXML (test_pyexpat.py
authorFred Drake <fdrake@acm.org>
Thu, 27 Jun 2002 19:41:51 +0000 (19:41 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 27 Jun 2002 19:41:51 +0000 (19:41 +0000)
revision 1.12 in PyXML).

Lib/test/test_pyexpat.py

index 404dc3553187fea201b43bebfd1aa74726f52887..22b3099b79b4161833771b2c3db7ffb3c4340c45 100644 (file)
@@ -200,3 +200,21 @@ else:
 # http://mail.python.org/pipermail/xml-sig/2001-April/005202.html
 #
 expat.ParserCreate(namespace_separator='') # too short
+
+# Test the interning machinery.
+p = expat.ParserCreate()
+L = []
+def collector(name, *args):
+    L.append(name)
+p.StartElementHandler = collector
+p.EndElementHandler = collector
+p.Parse("<e> <e/> <e></e> </e>", 1)
+tag = L[0]
+if len(L) != 6:
+    print "L should only contain 6 entries; found", len(L)
+for entry in L:
+    if tag is not entry:
+        print "expected L to contain many references to the same string",
+        print "(it didn't)"
+        print "L =", `L`
+        break