Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
52467b16
Kaydet (Commit)
52467b16
authored
Haz 01, 2012
tarafından
Eli Bendersky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #14007: make XMLParser a real subclassable type exported from _elementtree. +cleanups
üst
7e0229e9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
5 deletions
+34
-5
xml.etree.elementtree.rst
Doc/library/xml.etree.elementtree.rst
+5
-5
test_xml_etree.py
Lib/test/test_xml_etree.py
+29
-0
_elementtree.c
Modules/_elementtree.c
+0
-0
No files found.
Doc/library/xml.etree.elementtree.rst
Dosyayı görüntüle @
52467b16
...
...
@@ -646,8 +646,8 @@ ElementTree Objects
Loads an external XML section into this element tree. *source* is a file
name or :term:`file object`. *parser* is an optional parser instance.
If not given, the standard
XMLParser parser is used. Returns the section
root element.
If not given, the standard
:class:`XMLParser` parser is used. Returns the
section
root element.
.. method:: write(file, encoding="us-ascii", xml_declaration=None, method="xml")
...
...
@@ -767,9 +767,9 @@ XMLParser Objects
:class:`Element` structure builder for XML source data, based on the expat
parser. *html* are predefined HTML entities. This flag is not supported by
the current implementation. *target* is the target object. If omitted, the
builder uses an instance of the standard
TreeBuilder class. *encoding* [1]_
is optional. If given, the value overrides the encoding specified in the
XML file.
builder uses an instance of the standard
:class:`TreeBuilder` class.
*encoding* [1]_ is optional. If given, the value overrides the encoding
specified in the
XML file.
.. method:: close()
...
...
Lib/test/test_xml_etree.py
Dosyayı görüntüle @
52467b16
...
...
@@ -2028,6 +2028,34 @@ class TreeBuilderTest(unittest.TestCase):
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'
))
class
XMLParserTest
(
unittest
.
TestCase
):
sample1
=
'<file><line>22</line></file>'
def
_check_sample_element
(
self
,
e
):
self
.
assertEqual
(
e
.
tag
,
'file'
)
self
.
assertEqual
(
e
[
0
]
.
tag
,
'line'
)
self
.
assertEqual
(
e
[
0
]
.
text
,
'22'
)
def
test_constructor_args
(
self
):
# Positional args. The first (html) is not supported, but should be
# nevertheless correctly accepted.
parser
=
ET
.
XMLParser
(
None
,
ET
.
TreeBuilder
(),
'utf-8'
)
parser
.
feed
(
self
.
sample1
)
self
.
_check_sample_element
(
parser
.
close
())
# Now as keyword args.
parser2
=
ET
.
XMLParser
(
encoding
=
'utf-8'
,
html
=
[{}],
target
=
ET
.
TreeBuilder
())
parser2
.
feed
(
self
.
sample1
)
self
.
_check_sample_element
(
parser2
.
close
())
def
test_subclass
(
self
):
class
MyParser
(
ET
.
XMLParser
):
pass
parser
=
MyParser
()
parser
.
feed
(
self
.
sample1
)
self
.
_check_sample_element
(
parser
.
close
())
class
NoAcceleratorTest
(
unittest
.
TestCase
):
# Test that the C accelerator was not imported for pyET
def
test_correct_import_pyET
(
self
):
...
...
@@ -2245,6 +2273,7 @@ def test_main(module=pyET):
ElementTreeTest
,
NamespaceParseTest
,
TreeBuilderTest
,
XMLParserTest
,
KeywordArgsTest
]
if
module
is
pyET
:
# Run the tests specific to the Python implementation
...
...
Modules/_elementtree.c
Dosyayı görüntüle @
52467b16
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment