@@ -706,7 +706,7 @@ def comment(self, data):
706706 # Element.getchildren() and ElementTree.getiterator() are deprecated.
707707 @checkwarnings (("This method will be removed in future versions. "
708708 "Use .+ instead." ,
709- ( DeprecationWarning , PendingDeprecationWarning ) ))
709+ DeprecationWarning ))
710710 def test_getchildren (self ):
711711 # Test Element.getchildren()
712712
@@ -2399,7 +2399,7 @@ def test_iter_by_tag(self):
23992399
24002400 # Element.getiterator() is deprecated.
24012401 @checkwarnings (("This method will be removed in future versions. "
2402- "Use .+ instead." , PendingDeprecationWarning ))
2402+ "Use .+ instead." , DeprecationWarning ))
24032403 def test_getiterator (self ):
24042404 doc = ET .XML ('''
24052405 <document>
@@ -2605,14 +2605,6 @@ def _check_sample_element(self, e):
26052605 self .assertEqual (e [0 ].text , '22' )
26062606
26072607 def test_constructor_args (self ):
2608- # Positional args. The first (html) is not supported, but should be
2609- # nevertheless correctly accepted.
2610- with self .assertWarnsRegex (DeprecationWarning , r'\bhtml\b' ):
2611- parser = ET .XMLParser (None , ET .TreeBuilder (), 'utf-8' )
2612- parser .feed (self .sample1 )
2613- self ._check_sample_element (parser .close ())
2614-
2615- # Now as keyword args.
26162608 parser2 = ET .XMLParser (encoding = 'utf-8' ,
26172609 target = ET .TreeBuilder ())
26182610 parser2 .feed (self .sample1 )
@@ -2626,13 +2618,6 @@ class MyParser(ET.XMLParser):
26262618 self ._check_sample_element (parser .close ())
26272619
26282620 def test_doctype_warning (self ):
2629- parser = ET .XMLParser ()
2630- with self .assertWarns (DeprecationWarning ):
2631- parser .doctype ('html' , '-//W3C//DTD XHTML 1.0 Transitional//EN' ,
2632- 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd' )
2633- parser .feed ('<html/>' )
2634- parser .close ()
2635-
26362621 with warnings .catch_warnings ():
26372622 warnings .simplefilter ('error' , DeprecationWarning )
26382623 parser = ET .XMLParser ()
@@ -2642,21 +2627,20 @@ def test_doctype_warning(self):
26422627 def test_subclass_doctype (self ):
26432628 _doctype = None
26442629 class MyParserWithDoctype (ET .XMLParser ):
2645- def doctype (self , name , pubid , system ):
2630+ def doctype (self , * args , ** kwargs ):
26462631 nonlocal _doctype
2647- _doctype = (name , pubid , system )
2632+ _doctype = (args , kwargs )
26482633
26492634 parser = MyParserWithDoctype ()
2650- with self .assertWarns ( DeprecationWarning ):
2635+ with self .assertWarnsRegex ( RuntimeWarning , 'doctype' ):
26512636 parser .feed (self .sample2 )
26522637 parser .close ()
2653- self .assertEqual (_doctype ,
2654- ('html' , '-//W3C//DTD XHTML 1.0 Transitional//EN' ,
2655- 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd' ))
2638+ self .assertIsNone (_doctype )
26562639
26572640 _doctype = _doctype2 = None
26582641 with warnings .catch_warnings ():
26592642 warnings .simplefilter ('error' , DeprecationWarning )
2643+ warnings .simplefilter ('error' , RuntimeWarning )
26602644 class DoctypeParser :
26612645 def doctype (self , name , pubid , system ):
26622646 nonlocal _doctype2
@@ -2674,6 +2658,7 @@ def test_inherited_doctype(self):
26742658 '''Ensure that ordinary usage is not deprecated (Issue 19176)'''
26752659 with warnings .catch_warnings ():
26762660 warnings .simplefilter ('error' , DeprecationWarning )
2661+ warnings .simplefilter ('error' , RuntimeWarning )
26772662 class MyParserWithoutDoctype (ET .XMLParser ):
26782663 pass
26792664 parser = MyParserWithoutDoctype ()
0 commit comments