mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Added function xml.sax.saxutils.quoteattr().
This closes SF bug #440351. It should not be moved to Python 2.1.1.
This commit is contained in:
parent
3c033230ec
commit
acd32d3be5
4 changed files with 68 additions and 4 deletions
|
|
@ -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", {"å" : "å"}) == "Hei på deg"
|
||||
|
||||
# ===== quoteattr
|
||||
|
||||
def test_quoteattr_basic():
|
||||
return quoteattr("Donald Duck & Co") == '"Donald Duck & 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 "double" quotes\"")
|
||||
|
||||
# ===== make_parser
|
||||
|
||||
def test_make_parser():
|
||||
try:
|
||||
# Creating a parser should succeed - it should fall back
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue