@@ -705,7 +705,7 @@ def comment(self, data):
705705 # Element.getchildren() and ElementTree.getiterator() are deprecated.
706706 @checkwarnings (("This method will be removed in future versions. "
707707 "Use .+ instead." ,
708- ( DeprecationWarning , PendingDeprecationWarning ) ))
708+ DeprecationWarning ))
709709 def test_getchildren (self ):
710710 # Test Element.getchildren()
711711
@@ -2398,7 +2398,7 @@ def test_iter_by_tag(self):
23982398
23992399 # Element.getiterator() is deprecated.
24002400 @checkwarnings (("This method will be removed in future versions. "
2401- "Use .+ instead." , PendingDeprecationWarning ))
2401+ "Use .+ instead." , DeprecationWarning ))
24022402 def test_getiterator (self ):
24032403 doc = ET .XML ('''
24042404 <document>
@@ -2604,14 +2604,6 @@ def _check_sample_element(self, e):
26042604 self .assertEqual (e [0 ].text , '22' )
26052605
26062606 def test_constructor_args (self ):
2607- # Positional args. The first (html) is not supported, but should be
2608- # nevertheless correctly accepted.
2609- with self .assertWarnsRegex (DeprecationWarning , r'\bhtml\b' ):
2610- parser = ET .XMLParser (None , ET .TreeBuilder (), 'utf-8' )
2611- parser .feed (self .sample1 )
2612- self ._check_sample_element (parser .close ())
2613-
2614- # Now as keyword args.
26152607 parser2 = ET .XMLParser (encoding = 'utf-8' ,
26162608 target = ET .TreeBuilder ())
26172609 parser2 .feed (self .sample1 )
@@ -2625,13 +2617,6 @@ class MyParser(ET.XMLParser):
26252617 self ._check_sample_element (parser .close ())
26262618
26272619 def test_doctype_warning (self ):
2628- parser = ET .XMLParser ()
2629- with self .assertWarns (DeprecationWarning ):
2630- parser .doctype ('html' , '-//W3C//DTD XHTML 1.0 Transitional//EN' ,
2631- 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd' )
2632- parser .feed ('<html/>' )
2633- parser .close ()
2634-
26352620 with warnings .catch_warnings ():
26362621 warnings .simplefilter ('error' , DeprecationWarning )
26372622 parser = ET .XMLParser ()
@@ -2641,21 +2626,20 @@ def test_doctype_warning(self):
26412626 def test_subclass_doctype (self ):
26422627 _doctype = None
26432628 class MyParserWithDoctype (ET .XMLParser ):
2644- def doctype (self , name , pubid , system ):
2629+ def doctype (self , * args , ** kwargs ):
26452630 nonlocal _doctype
2646- _doctype = (name , pubid , system )
2631+ _doctype = (args , kwargs )
26472632
26482633 parser = MyParserWithDoctype ()
2649- with self .assertWarns ( DeprecationWarning ):
2634+ with self .assertWarnsRegex ( RuntimeWarning , 'doctype' ):
26502635 parser .feed (self .sample2 )
26512636 parser .close ()
2652- self .assertEqual (_doctype ,
2653- ('html' , '-//W3C//DTD XHTML 1.0 Transitional//EN' ,
2654- 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd' ))
2637+ self .assertIsNone (_doctype )
26552638
26562639 _doctype = _doctype2 = None
26572640 with warnings .catch_warnings ():
26582641 warnings .simplefilter ('error' , DeprecationWarning )
2642+ warnings .simplefilter ('error' , RuntimeWarning )
26592643 class DoctypeParser :
26602644 def doctype (self , name , pubid , system ):
26612645 nonlocal _doctype2
@@ -2673,6 +2657,7 @@ def test_inherited_doctype(self):
26732657 '''Ensure that ordinary usage is not deprecated (Issue 19176)'''
26742658 with warnings .catch_warnings ():
26752659 warnings .simplefilter ('error' , DeprecationWarning )
2660+ warnings .simplefilter ('error' , RuntimeWarning )
26762661 class MyParserWithoutDoctype (ET .XMLParser ):
26772662 pass
26782663 parser = MyParserWithoutDoctype ()
0 commit comments