mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 14:45:14 +00:00 
			
		
		
		
	Fix --netrc empty string parsing for Python <=3.10 (#11414)
				
					
				
			Ref: 15409c720b
Closes #11413
Authored by: bashonly, Grub4K
Co-authored-by: Simon Sawicki <contact@grub4k.xyz>
			
			
This commit is contained in:
		| @@ -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) | ||||
|   | ||||
							
								
								
									
										4
									
								
								test/testdata/netrc/netrc
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								test/testdata/netrc/netrc
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| machine normal_use login user password pass | ||||
| machine empty_user login "" password pass | ||||
| machine empty_pass login user password "" | ||||
| machine both_empty login "" password "" | ||||
							
								
								
									
										2
									
								
								test/testdata/netrc/print_netrc.py
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								test/testdata/netrc/print_netrc.py
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| with open('./test/testdata/netrc/netrc', encoding='utf-8') as fp: | ||||
|     print(fp.read()) | ||||
		Reference in New Issue
	
	Block a user
	 bashonly
					bashonly