mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-12-03 21:46:49 +02:00
[cleanup] Deprecate compat_etree_fromstring (#17625)
Authored by: doe1080
This commit is contained in:
+5
-8
@@ -21,10 +21,7 @@ import unittest.mock
|
||||
import warnings
|
||||
import xml.etree.ElementTree
|
||||
|
||||
from yt_dlp.compat import (
|
||||
compat_etree_fromstring,
|
||||
compat_HTMLParseError,
|
||||
)
|
||||
from yt_dlp.compat import compat_HTMLParseError
|
||||
from yt_dlp.utils import (
|
||||
Config,
|
||||
DateRange,
|
||||
@@ -530,7 +527,7 @@ class TestUtil(unittest.TestCase):
|
||||
<node x="" />
|
||||
<node x="a'b"c" y="1" />
|
||||
</root>'''
|
||||
doc = compat_etree_fromstring(testxml)
|
||||
doc = xml.etree.ElementTree.fromstring(testxml)
|
||||
|
||||
self.assertEqual(find_xpath_attr(doc, './/fourohfour', 'n'), None)
|
||||
self.assertEqual(find_xpath_attr(doc, './/fourohfour', 'n', 'v'), None)
|
||||
@@ -553,7 +550,7 @@ class TestUtil(unittest.TestCase):
|
||||
<url>http://server.com/download.mp3</url>
|
||||
</media:song>
|
||||
</root>'''
|
||||
doc = compat_etree_fromstring(testxml)
|
||||
doc = xml.etree.ElementTree.fromstring(testxml)
|
||||
find = lambda p: doc.find(xpath_with_ns(p, {'media': 'http://example.com/'}))
|
||||
self.assertTrue(find('media:song') is not None)
|
||||
self.assertEqual(find('media:song/media:author').text, 'The Author')
|
||||
@@ -586,7 +583,7 @@ class TestUtil(unittest.TestCase):
|
||||
<p>Foo</p>
|
||||
</div>
|
||||
</root>'''
|
||||
doc = compat_etree_fromstring(testxml)
|
||||
doc = xml.etree.ElementTree.fromstring(testxml)
|
||||
self.assertEqual(xpath_text(doc, 'div/p'), 'Foo')
|
||||
self.assertEqual(xpath_text(doc, 'div/bar', default='default'), 'default')
|
||||
self.assertTrue(xpath_text(doc, 'div/bar') is None)
|
||||
@@ -598,7 +595,7 @@ class TestUtil(unittest.TestCase):
|
||||
<p x="a">Foo</p>
|
||||
</div>
|
||||
</root>'''
|
||||
doc = compat_etree_fromstring(testxml)
|
||||
doc = xml.etree.ElementTree.fromstring(testxml)
|
||||
self.assertEqual(xpath_attr(doc, 'div/p', 'x'), 'a')
|
||||
self.assertEqual(xpath_attr(doc, 'div/bar', 'x'), None)
|
||||
self.assertEqual(xpath_attr(doc, 'div/p', 'y'), None)
|
||||
|
||||
Reference in New Issue
Block a user