Skip to content

Commit

Permalink
[test_YoutubeDL] Add tests for #10591 (closes #23873)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw authored and pareronia committed Jun 22, 2020
1 parent 6b73bfc commit c7e3f8b
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions test/test_YoutubeDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,12 +816,15 @@ def test_playlist_items_selection(self):
'webpage_url': 'http://example.com',
}

def get_ids(params):
def get_downloaded_info_dicts(params):
ydl = YDL(params)
# make a deep copy because the dictionary and nested entries
# can be modified
ydl.process_ie_result(copy.deepcopy(playlist))
return [int(v['id']) for v in ydl.downloaded_info_dicts]
return ydl.downloaded_info_dicts

def get_ids(params):
return [int(v['id']) for v in get_downloaded_info_dicts(params)]

result = get_ids({})
self.assertEqual(result, [1, 2, 3, 4])
Expand Down Expand Up @@ -853,6 +856,22 @@ def get_ids(params):
result = get_ids({'playlist_items': '2-4,3-4,3'})
self.assertEqual(result, [2, 3, 4])

# Tests for https://github.com/ytdl-org/youtube-dl/issues/10591
# @{
result = get_downloaded_info_dicts({'playlist_items': '2-4,3-4,3'})
self.assertEqual(result[0]['playlist_index'], 2)
self.assertEqual(result[1]['playlist_index'], 3)

result = get_downloaded_info_dicts({'playlist_items': '2-4,3-4,3'})
self.assertEqual(result[0]['playlist_index'], 2)
self.assertEqual(result[1]['playlist_index'], 3)
self.assertEqual(result[2]['playlist_index'], 4)

result = get_downloaded_info_dicts({'playlist_items': '4,2'})
self.assertEqual(result[0]['playlist_index'], 4)
self.assertEqual(result[1]['playlist_index'], 2)
# @}

def test_urlopen_no_file_protocol(self):
# see https://github.com/ytdl-org/youtube-dl/issues/8227
ydl = YDL()
Expand Down

0 comments on commit c7e3f8b

Please sign in to comment.