summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-07-19 16:10:15 (GMT)
committerFred Drake <fdrake@acm.org>2001-07-19 16:10:15 (GMT)
commitacd32d3be542987078c65a8a34d7844cfa7ebbe8 (patch)
treee3ff8c129dd9cc8d18a9cdf06b0fab20943554bb /Lib/test
parent3c033230ec2f81c9d61ba1b1f19a99f8bf4f4bd3 (diff)
downloadcpython-acd32d3be542987078c65a8a34d7844cfa7ebbe8.zip
cpython-acd32d3be542987078c65a8a34d7844cfa7ebbe8.tar.gz
cpython-acd32d3be542987078c65a8a34d7844cfa7ebbe8.tar.bz2
Added function xml.sax.saxutils.quoteattr().
This closes SF bug #440351. It should not be moved to Python 2.1.1.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/output/test_sax6
-rw-r--r--Lib/test/test_sax.py21
2 files changed, 25 insertions, 2 deletions
diff --git a/Lib/test/output/test_sax b/Lib/test/output/test_sax
index de49c80..b14cf94 100644
--- a/Lib/test/output/test_sax
+++ b/Lib/test/output/test_sax
@@ -1,6 +1,7 @@
test_sax
Passed test_attrs_empty
Passed test_attrs_wattr
+Passed test_double_quoteattr
Passed test_escape_all
Passed test_escape_basic
Passed test_escape_extra
@@ -25,10 +26,13 @@ Passed test_make_parser
Passed test_make_parser2
Passed test_nsattrs_empty
Passed test_nsattrs_wattr
+Passed test_quoteattr_basic
+Passed test_single_double_quoteattr
+Passed test_single_quoteattr
Passed test_xmlgen_basic
Passed test_xmlgen_content
Passed test_xmlgen_content_escape
Passed test_xmlgen_ignorable
Passed test_xmlgen_ns
Passed test_xmlgen_pi
-32 tests, 0 failures
+36 tests, 0 failures
diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py
index f4b43fe..62705c9 100644
--- a/Lib/test/test_sax.py
+++ b/Lib/test/test_sax.py
@@ -8,7 +8,7 @@ try:
except SAXReaderNotAvailable:
# don't try to test this module if we cannot create a parser
raise ImportError("no XML parsers available")
-from xml.sax.saxutils import XMLGenerator, escape, XMLFilterBase
+from xml.sax.saxutils import XMLGenerator, escape, quoteattr, XMLFilterBase
from xml.sax.expatreader import create_parser
from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
from cStringIO import StringIO
@@ -69,6 +69,25 @@ def test_escape_all():
def test_escape_extra():
return escape("Hei på deg", {"å" : "&aring;"}) == "Hei p&aring; deg"
+# ===== quoteattr
+
+def test_quoteattr_basic():
+ return quoteattr("Donald Duck & Co") == '"Donald Duck &amp; Co"'
+
+def test_single_quoteattr():
+ return (quoteattr('Includes "double" quotes')
+ == '\'Includes "double" quotes\'')
+
+def test_double_quoteattr():
+ return (quoteattr("Includes 'single' quotes")
+ == "\"Includes 'single' quotes\"")
+
+def test_single_double_quoteattr():
+ return (quoteattr("Includes 'single' and \"double\" quotes")
+ == "\"Includes 'single' and &quot;double&quot; quotes\"")
+
+# ===== make_parser
+
def test_make_parser():
try:
# Creating a parser should succeed - it should fall back