mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 14:45:14 +00:00 
			
		
		
		
	Merge branch 'paged-lists'
Conflicts: test/test_utils.py youtube_dl/extractor/youtube.py
This commit is contained in:
		| @@ -19,6 +19,7 @@ from youtube_dl.utils import ( | ||||
|     fix_xml_ampersands, | ||||
|     get_meta_content, | ||||
|     orderedSet, | ||||
|     PagedList, | ||||
|     parse_duration, | ||||
|     sanitize_filename, | ||||
|     shell_quote, | ||||
| @@ -214,5 +215,26 @@ class TestUtil(unittest.TestCase): | ||||
|             fix_xml_ampersands('Ӓ᪼'), 'Ӓ᪼') | ||||
|         self.assertEqual(fix_xml_ampersands('&#&#'), '&#&#') | ||||
|  | ||||
|     def test_paged_list(self): | ||||
|         def testPL(size, pagesize, sliceargs, expected): | ||||
|             def get_page(pagenum): | ||||
|                 firstid = pagenum * pagesize | ||||
|                 upto = min(size, pagenum * pagesize + pagesize) | ||||
|                 for i in range(firstid, upto): | ||||
|                     yield i | ||||
|  | ||||
|             pl = PagedList(get_page, pagesize) | ||||
|             got = pl.getslice(*sliceargs) | ||||
|             self.assertEqual(got, expected) | ||||
|  | ||||
|         testPL(5, 2, (), [0, 1, 2, 3, 4]) | ||||
|         testPL(5, 2, (1,), [1, 2, 3, 4]) | ||||
|         testPL(5, 2, (2,), [2, 3, 4]) | ||||
|         testPL(5, 2, (4,), [4]) | ||||
|         testPL(5, 2, (0, 3), [0, 1, 2]) | ||||
|         testPL(5, 2, (1, 4), [1, 2, 3]) | ||||
|         testPL(5, 2, (2, 99), [2, 3, 4]) | ||||
|         testPL(5, 2, (20, 99), []) | ||||
|  | ||||
| if __name__ == '__main__': | ||||
|     unittest.main() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Philipp Hagemeister
					Philipp Hagemeister