aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Sawicki <contact@grub4k.xyz>2024-11-02 21:42:00 +0100
committerGitHub <noreply@github.com>2024-11-02 21:42:00 +0100
commit422195ec70a00b0d2002b238cacbae7790c57fdf (patch)
tree0edaea18bb0e9b3ed8cab70fc82c7a0a09633ea2 /test
parenta6783a3b9905e547f6c1d4df9d7c7999feda8afa (diff)
[utils] Allow partial application for even more functions (#11437)
Fixes b6dc2c49e8793c6dfa21275e61caf49ec1148b81 Authored by: Grub4K
Diffstat (limited to 'test')
-rw-r--r--test/test_traversal.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_traversal.py b/test/test_traversal.py
index f1d123bd6..1c0cc5362 100644
--- a/test/test_traversal.py
+++ b/test/test_traversal.py
@@ -9,6 +9,7 @@ from yt_dlp.utils import (
determine_ext,
dict_get,
int_or_none,
+ join_nonempty,
str_or_none,
)
from yt_dlp.utils.traversal import (
@@ -16,6 +17,7 @@ from yt_dlp.utils.traversal import (
subs_list_to_dict,
traverse_obj,
trim_str,
+ unpack,
)
_TEST_DATA = {
@@ -510,6 +512,15 @@ class TestTraversalHelpers:
assert trim_str(start='abc', end='abc')('abc') == ''
assert trim_str(start='', end='')('abc') == 'abc'
+ def test_unpack(self):
+ assert unpack(lambda *x: ''.join(map(str, x)))([1, 2, 3]) == '123'
+ assert unpack(join_nonempty)([1, 2, 3]) == '1-2-3'
+ assert unpack(join_nonempty(delim=' '))([1, 2, 3]) == '1 2 3'
+ with pytest.raises(TypeError):
+ unpack(join_nonempty)()
+ with pytest.raises(TypeError):
+ unpack()
+
class TestDictGet:
def test_dict_get(self):