diff options
author | bashonly <88596187+bashonly@users.noreply.github.com> | 2024-10-30 21:53:41 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-30 21:53:41 +0000 |
commit | b6dc2c49e8793c6dfa21275e61caf49ec1148b81 (patch) | |
tree | 68e44258d8f6aba23f71e449316639008bfd3a4c /test/test_traversal.py | |
parent | 76802f461332d444e596437c42374fa237fa5174 (diff) |
[utils] Allow partial application for more functions (#11391)
Also adds the `trim_str` traversal helper
Authored by: bashonly, Grub4K
Co-authored-by: Simon Sawicki <contact@grub4k.xyz>
Diffstat (limited to 'test/test_traversal.py')
-rw-r--r-- | test/test_traversal.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/test/test_traversal.py b/test/test_traversal.py index 9179dadda..f1d123bd6 100644 --- a/test/test_traversal.py +++ b/test/test_traversal.py @@ -12,9 +12,10 @@ from yt_dlp.utils import ( str_or_none, ) from yt_dlp.utils.traversal import ( - traverse_obj, require, subs_list_to_dict, + traverse_obj, + trim_str, ) _TEST_DATA = { @@ -495,6 +496,20 @@ class TestTraversalHelpers: {'url': 'https://example.com/subs/en2', 'ext': 'ext'}, ]}, '`quality` key should sort subtitle list accordingly' + def test_trim_str(self): + with pytest.raises(TypeError): + trim_str('positional') + + assert callable(trim_str(start='a')) + assert trim_str(start='ab')('abc') == 'c' + assert trim_str(end='bc')('abc') == 'a' + assert trim_str(start='a', end='c')('abc') == 'b' + assert trim_str(start='ab', end='c')('abc') == '' + assert trim_str(start='a', end='bc')('abc') == '' + assert trim_str(start='ab', end='bc')('abc') == '' + assert trim_str(start='abc', end='abc')('abc') == '' + assert trim_str(start='', end='')('abc') == 'abc' + class TestDictGet: def test_dict_get(self): |