|
|
@ -42,6 +42,7 @@ from youtube_dl.utils import ( |
|
|
|
is_html, |
|
|
|
js_to_json, |
|
|
|
limit_length, |
|
|
|
merge_dicts, |
|
|
|
mimetype2ext, |
|
|
|
month_by_name, |
|
|
|
multipart_encode, |
|
|
@ -669,6 +670,17 @@ class TestUtil(unittest.TestCase): |
|
|
|
self.assertEqual(dict_get(d, ('b', 'c', key, )), None) |
|
|
|
self.assertEqual(dict_get(d, ('b', 'c', key, ), skip_false_values=False), false_value) |
|
|
|
|
|
|
|
def test_merge_dicts(self): |
|
|
|
self.assertEqual(merge_dicts({'a': 1}, {'b': 2}), {'a': 1, 'b': 2}) |
|
|
|
self.assertEqual(merge_dicts({'a': 1}, {'a': 2}), {'a': 1}) |
|
|
|
self.assertEqual(merge_dicts({'a': 1}, {'a': None}), {'a': 1}) |
|
|
|
self.assertEqual(merge_dicts({'a': 1}, {'a': ''}), {'a': 1}) |
|
|
|
self.assertEqual(merge_dicts({'a': 1}, {}), {'a': 1}) |
|
|
|
self.assertEqual(merge_dicts({'a': None}, {'a': 1}), {'a': 1}) |
|
|
|
self.assertEqual(merge_dicts({'a': ''}, {'a': 1}), {'a': ''}) |
|
|
|
self.assertEqual(merge_dicts({'a': ''}, {'a': 'abc'}), {'a': 'abc'}) |
|
|
|
self.assertEqual(merge_dicts({'a': None}, {'a': ''}, {'a': 'abc'}), {'a': 'abc'}) |
|
|
|
|
|
|
|
def test_encode_compat_str(self): |
|
|
|
self.assertEqual(encode_compat_str(b'\xd1\x82\xd0\xb5\xd1\x81\xd1\x82', 'utf-8'), 'тест') |
|
|
|
self.assertEqual(encode_compat_str('тест', 'utf-8'), 'тест') |
|
|
|