hbmartin commited on
Commit
0cf8d94
·
1 Parent(s): 811e7aa

mock request.get in test_playlist

Browse files
pytube/helpers.py CHANGED
@@ -102,8 +102,9 @@ def create_logger(level: int = logging.ERROR) -> logging.Logger:
102
  return logger
103
 
104
 
105
- T = TypeVar("T")
106
 
107
 
108
- def cache(func: Callable[..., T]) -> T:
 
109
  return functools.lru_cache()(func) # type: ignore
 
102
  return logger
103
 
104
 
105
+ GenericType = TypeVar("T")
106
 
107
 
108
+ def cache(func: Callable[..., GenericType]) -> GenericType:
109
+ """ mypy compatible annotation wrapper for lru_cache"""
110
  return functools.lru_cache()(func) # type: ignore
tests/contrib/test_playlist.py CHANGED
@@ -1,11 +1,13 @@
1
  # -*- coding: utf-8 -*-
 
2
  from unittest.mock import MagicMock
3
 
4
  from pytube import Playlist
5
 
6
 
7
-
8
- def test_title():
 
9
  list_key = "PLsyeobzWxl7poL9JTVyndKe62ieoN-MZ3"
10
  url = "https://www.fakeurl.com/playlist?list=" + list_key
11
  pl = Playlist(url)
 
1
  # -*- coding: utf-8 -*-
2
+ from unittest import mock
3
  from unittest.mock import MagicMock
4
 
5
  from pytube import Playlist
6
 
7
 
8
+ @mock.patch("request.get")
9
+ def test_title(request_get):
10
+ request_get.return_value = ""
11
  list_key = "PLsyeobzWxl7poL9JTVyndKe62ieoN-MZ3"
12
  url = "https://www.fakeurl.com/playlist?list=" + list_key
13
  pl = Playlist(url)