remove unused import
Browse files- tests/test_exceptions.py +1 -1
- tests/test_main.py +6 -2
- tests/test_streams.py +16 -10
tests/test_exceptions.py
CHANGED
@@ -4,6 +4,6 @@ from pytube.exceptions import VideoUnavailable
|
|
4 |
|
5 |
def test_is_expected():
|
6 |
try:
|
7 |
-
raise VideoUnavailable(
|
8 |
except VideoUnavailable as e:
|
9 |
assert e.video_id == "YLnZklYFe7E"
|
|
|
4 |
|
5 |
def test_is_expected():
|
6 |
try:
|
7 |
+
raise VideoUnavailable(video_id="YLnZklYFe7E")
|
8 |
except VideoUnavailable as e:
|
9 |
assert e.video_id == "YLnZklYFe7E"
|
tests/test_main.py
CHANGED
@@ -14,6 +14,10 @@ def test_prefetch_deferred(MockYouTube):
|
|
14 |
|
15 |
@mock.patch("urllib.request.install_opener")
|
16 |
def test_install_proxy(opener):
|
17 |
-
proxies = {
|
18 |
-
YouTube(
|
|
|
|
|
|
|
|
|
19 |
opener.assert_called()
|
|
|
14 |
|
15 |
@mock.patch("urllib.request.install_opener")
|
16 |
def test_install_proxy(opener):
|
17 |
+
proxies = {"http": "http://www.example.com:3128/"}
|
18 |
+
YouTube(
|
19 |
+
"https://www.youtube.com/watch?v=9bZkp7q19f0",
|
20 |
+
defer_prefetch_init=True,
|
21 |
+
proxies=proxies,
|
22 |
+
)
|
23 |
opener.assert_called()
|
tests/test_streams.py
CHANGED
@@ -3,8 +3,6 @@ import random
|
|
3 |
|
4 |
from unittest import mock
|
5 |
|
6 |
-
import pytest
|
7 |
-
|
8 |
from pytube import request
|
9 |
from pytube import Stream
|
10 |
|
@@ -125,27 +123,35 @@ def test_thumbnail_when_not_in_details(cipher_signature):
|
|
125 |
|
126 |
def test_repr_for_audio_streams(cipher_signature):
|
127 |
stream = str(cipher_signature.streams.filter(only_audio=True).first())
|
128 |
-
expected =
|
129 |
-
|
|
|
|
|
130 |
assert stream == expected
|
131 |
|
132 |
|
133 |
def test_repr_for_video_streams(cipher_signature):
|
134 |
stream = str(cipher_signature.streams.filter(only_video=True).first())
|
135 |
-
expected =
|
136 |
-
|
|
|
|
|
137 |
assert stream == expected
|
138 |
|
139 |
|
140 |
def test_repr_for_progressive_streams(cipher_signature):
|
141 |
stream = str(cipher_signature.streams.filter(progressive=True).first())
|
142 |
-
expected =
|
143 |
-
|
|
|
|
|
144 |
assert stream == expected
|
145 |
|
146 |
|
147 |
def test_repr_for_adaptive_streams(cipher_signature):
|
148 |
stream = str(cipher_signature.streams.filter(adaptive=True).first())
|
149 |
-
expected =
|
150 |
-
|
|
|
|
|
151 |
assert stream == expected
|
|
|
3 |
|
4 |
from unittest import mock
|
5 |
|
|
|
|
|
6 |
from pytube import request
|
7 |
from pytube import Stream
|
8 |
|
|
|
123 |
|
124 |
def test_repr_for_audio_streams(cipher_signature):
|
125 |
stream = str(cipher_signature.streams.filter(only_audio=True).first())
|
126 |
+
expected = (
|
127 |
+
'<Stream: itag="140" mime_type="audio/mp4" abr="128kbps" '
|
128 |
+
'acodec="mp4a.40.2" progressive="False" type="audio">'
|
129 |
+
)
|
130 |
assert stream == expected
|
131 |
|
132 |
|
133 |
def test_repr_for_video_streams(cipher_signature):
|
134 |
stream = str(cipher_signature.streams.filter(only_video=True).first())
|
135 |
+
expected = (
|
136 |
+
'<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" '
|
137 |
+
'vcodec="avc1.640028" progressive="False" type="video">'
|
138 |
+
)
|
139 |
assert stream == expected
|
140 |
|
141 |
|
142 |
def test_repr_for_progressive_streams(cipher_signature):
|
143 |
stream = str(cipher_signature.streams.filter(progressive=True).first())
|
144 |
+
expected = (
|
145 |
+
'<Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" '
|
146 |
+
'vcodec="avc1.42001E" acodec="mp4a.40.2" progressive="True" type="video">'
|
147 |
+
)
|
148 |
assert stream == expected
|
149 |
|
150 |
|
151 |
def test_repr_for_adaptive_streams(cipher_signature):
|
152 |
stream = str(cipher_signature.streams.filter(adaptive=True).first())
|
153 |
+
expected = (
|
154 |
+
'<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" '
|
155 |
+
'vcodec="avc1.640028" progressive="False" type="video">'
|
156 |
+
)
|
157 |
assert stream == expected
|