hbmartin commited on
Commit
0bbb369
·
1 Parent(s): 3783a2f

test main raises VideoUnavailable

Browse files
Files changed (1) hide show
  1. tests/test_main.py +13 -0
tests/test_main.py CHANGED
@@ -1,7 +1,10 @@
1
  # -*- coding: utf-8 -*-
2
  from unittest import mock
3
 
 
 
4
  from pytube import YouTube
 
5
 
6
 
7
  @mock.patch("pytube.__main__.YouTube")
@@ -21,3 +24,13 @@ def test_install_proxy(opener):
21
  proxies=proxies,
22
  )
23
  opener.assert_called()
 
 
 
 
 
 
 
 
 
 
 
1
  # -*- coding: utf-8 -*-
2
  from unittest import mock
3
 
4
+ import pytest
5
+
6
  from pytube import YouTube
7
+ from pytube.exceptions import VideoUnavailable
8
 
9
 
10
  @mock.patch("pytube.__main__.YouTube")
 
24
  proxies=proxies,
25
  )
26
  opener.assert_called()
27
+
28
+
29
+ @mock.patch("pytube.request.get")
30
+ def test_video_unavailable(get):
31
+ get.return_value = None
32
+ youtube = YouTube(
33
+ "https://www.youtube.com/watch?v=9bZkp7q19f0", defer_prefetch_init=True
34
+ )
35
+ with pytest.raises(VideoUnavailable):
36
+ youtube.prefetch()