Nick Ficano
commited on
Commit
·
28f27a6
1
Parent(s):
6d999e1
use None instead of False, comment cleanup
Browse files- pytube/api.py +2 -2
- tests/test_pytube.py +7 -3
pytube/api.py
CHANGED
@@ -65,7 +65,7 @@ class YouTube(object):
|
|
65 |
"""
|
66 |
self._filename = None
|
67 |
self._video_url = None
|
68 |
-
self._js_cache =
|
69 |
self._videos = []
|
70 |
if url:
|
71 |
self.from_url(url)
|
@@ -194,7 +194,7 @@ class YouTube(object):
|
|
194 |
url = "{}&signature={}".format(url, signature)
|
195 |
self._add_video(url, self.filename, **quality_profile)
|
196 |
# Clear the cached js. Make sure to keep this at the end of
|
197 |
-
# ``from_url()`` so we can mock inject the js in tests.
|
198 |
self._js_cache = None
|
199 |
|
200 |
def get(self, extension=None, resolution=None, profile=None):
|
|
|
65 |
"""
|
66 |
self._filename = None
|
67 |
self._video_url = None
|
68 |
+
self._js_cache = None
|
69 |
self._videos = []
|
70 |
if url:
|
71 |
self.from_url(url)
|
|
|
194 |
url = "{}&signature={}".format(url, signature)
|
195 |
self._add_video(url, self.filename, **quality_profile)
|
196 |
# Clear the cached js. Make sure to keep this at the end of
|
197 |
+
# ``from_url()`` so we can mock inject the js in unit tests.
|
198 |
self._js_cache = None
|
199 |
|
200 |
def get(self, extension=None, resolution=None, profile=None):
|
tests/test_pytube.py
CHANGED
@@ -10,8 +10,12 @@ from pytube.exceptions import MultipleObjectsReturned
|
|
10 |
class TestPytube(object):
|
11 |
def setUp(self):
|
12 |
url = 'http://www.youtube.com/watch?v=9bZkp7q19f0'
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
with mock.patch('pytube.api.urlopen') as urlopen:
|
16 |
urlopen.return_value.read.return_value = self.mock_html
|
17 |
self.yt = api.YouTube()
|
@@ -65,7 +69,7 @@ class TestPytube(object):
|
|
65 |
|
66 |
@raises(MultipleObjectsReturned)
|
67 |
def test_get_multiple_itmes(self):
|
68 |
-
"""
|
69 |
self.yt.get(profile='Simple')
|
70 |
self.yt.get('mp4')
|
71 |
self.yt.get(resolution='240p')
|
|
|
10 |
class TestPytube(object):
|
11 |
def setUp(self):
|
12 |
url = 'http://www.youtube.com/watch?v=9bZkp7q19f0'
|
13 |
+
with open('tests/mock_video.js') as fh:
|
14 |
+
self.mock_js = fh.read()
|
15 |
+
|
16 |
+
with open('tests/mock_video.html') as fh:
|
17 |
+
self.mock_html = fh.read()
|
18 |
+
|
19 |
with mock.patch('pytube.api.urlopen') as urlopen:
|
20 |
urlopen.return_value.read.return_value = self.mock_html
|
21 |
self.yt = api.YouTube()
|
|
|
69 |
|
70 |
@raises(MultipleObjectsReturned)
|
71 |
def test_get_multiple_itmes(self):
|
72 |
+
"""get(...) cannot return more than one video"""
|
73 |
self.yt.get(profile='Simple')
|
74 |
self.yt.get('mp4')
|
75 |
self.yt.get(resolution='240p')
|