hbmartin commited on
Commit
cf1c020
·
1 Parent(s): 1319b15

test playlist.videos

Browse files
pytube/contrib/playlist.py CHANGED
@@ -88,8 +88,6 @@ class Playlist:
88
 
89
  @property
90
  def videos(self) -> Iterable[YouTube]:
91
- if not self.video_urls:
92
- self.populate_video_urls()
93
  for url in self.video_urls:
94
  yield YouTube(url)
95
 
 
88
 
89
  @property
90
  def videos(self) -> Iterable[YouTube]:
 
 
91
  for url in self.video_urls:
92
  yield YouTube(url)
93
 
tests/contrib/test_playlist.py CHANGED
@@ -84,3 +84,14 @@ def test_video_urls(request_get, playlist_html):
84
  "https://www.youtube.com/watch?v=g1Zbuk1gAfk",
85
  "https://www.youtube.com/watch?v=zixd-si9Q-o",
86
  ]
 
 
 
 
 
 
 
 
 
 
 
 
84
  "https://www.youtube.com/watch?v=g1Zbuk1gAfk",
85
  "https://www.youtube.com/watch?v=zixd-si9Q-o",
86
  ]
87
+
88
+
89
+ @mock.patch("pytube.contrib.playlist.request.get")
90
+ @mock.patch("pytube.cli.YouTube.__init__", return_value=None)
91
+ def test_video_urls(youtube, request_get, playlist_html):
92
+ url = "https://www.fakeurl.com/playlist?list=whatever"
93
+ request_get.return_value = playlist_html
94
+ playlist = Playlist(url)
95
+ playlist._find_load_more_url = MagicMock(return_value=None)
96
+ request_get.assert_called()
97
+ assert len(list(playlist.videos)) == 12