added tests for deprecation warnings
Browse files- tests/test_pytube.py +29 -1
tests/test_pytube.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
#!/usr/bin/env/python
|
2 |
# -*- coding: utf-8 -*-
|
3 |
from __future__ import unicode_literals
|
4 |
-
|
5 |
import mock
|
6 |
from nose.tools import eq_, raises
|
7 |
from pytube import api
|
@@ -94,3 +94,31 @@ class TestPytube(object):
|
|
94 |
urlopen.return_value.read.return_value = mock_html
|
95 |
yt = api.YouTube()
|
96 |
yt.from_url(url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
#!/usr/bin/env/python
|
2 |
# -*- coding: utf-8 -*-
|
3 |
from __future__ import unicode_literals
|
4 |
+
import warnings
|
5 |
import mock
|
6 |
from nose.tools import eq_, raises
|
7 |
from pytube import api
|
|
|
94 |
urlopen.return_value.read.return_value = mock_html
|
95 |
yt = api.YouTube()
|
96 |
yt.from_url(url)
|
97 |
+
|
98 |
+
def test_deprecation_warnings_on_url_set(self):
|
99 |
+
"""Deprecation warnings get triggered on url set"""
|
100 |
+
with warnings.catch_warnings(record=True) as w:
|
101 |
+
# Cause all warnings to always be triggered.
|
102 |
+
warnings.simplefilter("always")
|
103 |
+
with mock.patch('pytube.api.urlopen') as urlopen:
|
104 |
+
urlopen.return_value.read.return_value = self.mock_html
|
105 |
+
yt = api.YouTube()
|
106 |
+
yt._js_cache = self.mock_js
|
107 |
+
yt.url = 'http://www.youtube.com/watch?v=9bZkp7q19f0'
|
108 |
+
eq_(len(w), 1)
|
109 |
+
|
110 |
+
def test_deprecation_warnings_on_filename_set(self):
|
111 |
+
"""Deprecation warnings get triggered on filename set"""
|
112 |
+
with warnings.catch_warnings(record=True) as w:
|
113 |
+
# Cause all warnings to always be triggered.
|
114 |
+
warnings.simplefilter("always")
|
115 |
+
self.yt.filename = 'Gangnam Style'
|
116 |
+
eq_(len(w), 1)
|
117 |
+
|
118 |
+
def test_deprecation_warnings_on_videos_get(self):
|
119 |
+
"""Deprecation warnings get triggered on video getter"""
|
120 |
+
with warnings.catch_warnings(record=True) as w:
|
121 |
+
# Cause all warnings to always be triggered.
|
122 |
+
warnings.simplefilter("always")
|
123 |
+
self.yt.videos
|
124 |
+
eq_(len(w), 1)
|