aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorYen Chi Hsuan <yan12125@gmail.com>2016-07-06 20:02:52 +0800
committerYen Chi Hsuan <yan12125@gmail.com>2016-07-06 20:02:52 +0800
commit84c237fb8a2afa06fd3c36f7da9517682e63480e (patch)
tree4bc87148026bb3bd6ed279d3f354eaf0004e97e4 /test
parentab49d7a9fae08763de549f85ba138b22f9122a99 (diff)
[utils] Add get_element_by_class
For #9950
Diffstat (limited to 'test')
-rw-r--r--test/test_utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/test_utils.py b/test/test_utils.py
index 85928dbc2..afd273a65 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -33,6 +33,7 @@ from youtube_dl.utils import (
ExtractorError,
find_xpath_attr,
fix_xml_ampersands,
+ get_element_by_class,
InAdvancePagedList,
intlist_to_bytes,
is_html,
@@ -991,5 +992,13 @@ The first line
self.assertEqual(urshift(3, 1), 1)
self.assertEqual(urshift(-3, 1), 2147483646)
+ def test_get_element_by_class(self):
+ html = '''
+ <span class="foo bar">nice</span>
+ '''
+
+ self.assertEqual(get_element_by_class('foo', html), 'nice')
+ self.assertEqual(get_element_by_class('no-such-class', html), None)
+
if __name__ == '__main__':
unittest.main()