aboutsummaryrefslogtreecommitdiff
path: root/test/test_InfoExtractor.py
diff options
context:
space:
mode:
authorbashonly <bashonly@protonmail.com>2024-10-30 13:40:07 -0500
committerbashonly <88596187+bashonly@users.noreply.github.com>2024-10-30 18:58:50 +0000
commit88402b714ec124633933737bc156b172a3dec3d6 (patch)
tree2ba54d621c6243f95e5e8fef7f04dcfce2662919 /test/test_InfoExtractor.py
parent5bc5fb2835ea59bdf326bd12176d74d2c7348a95 (diff)
Fix `--netrc` empty string parsing for Python <=3.10 (#11414)
Ref: https://github.com/python/cpython/commit/15409c720be0503131713e3d3abc1acd0da07378 Closes #11413 Authored by: bashonly, Grub4K Co-authored-by: Simon Sawicki <contact@grub4k.xyz>
Diffstat (limited to 'test/test_InfoExtractor.py')
-rw-r--r--test/test_InfoExtractor.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/test_InfoExtractor.py b/test/test_InfoExtractor.py
index 31e8f8244..54f35ef55 100644
--- a/test/test_InfoExtractor.py
+++ b/test/test_InfoExtractor.py
@@ -53,6 +53,18 @@ class TestInfoExtractor(unittest.TestCase):
def test_ie_key(self):
self.assertEqual(get_info_extractor(YoutubeIE.ie_key()), YoutubeIE)
+ def test_get_netrc_login_info(self):
+ for params in [
+ {'usenetrc': True, 'netrc_location': './test/testdata/netrc/netrc'},
+ {'netrc_cmd': f'{sys.executable} ./test/testdata/netrc/print_netrc.py'},
+ ]:
+ ie = DummyIE(FakeYDL(params))
+ self.assertEqual(ie._get_netrc_login_info(netrc_machine='normal_use'), ('user', 'pass'))
+ self.assertEqual(ie._get_netrc_login_info(netrc_machine='empty_user'), ('', 'pass'))
+ self.assertEqual(ie._get_netrc_login_info(netrc_machine='empty_pass'), ('user', ''))
+ self.assertEqual(ie._get_netrc_login_info(netrc_machine='both_empty'), ('', ''))
+ self.assertEqual(ie._get_netrc_login_info(netrc_machine='nonexistent'), (None, None))
+
def test_html_search_regex(self):
html = '<p id="foo">Watch this <a href="http://www.youtube.com/watch?v=BaW_jenozKc">video</a></p>'
search = lambda re, *args: self.ie._html_search_regex(re, html, *args)