hbmartin commited on
Commit
9fb6343
·
1 Parent(s): cc30577

test for proxy install

Browse files
Files changed (3) hide show
  1. pytube/cipher.py +5 -1
  2. tests/test_main.py +7 -0
  3. tests/test_streams.py +8 -4
pytube/cipher.py CHANGED
@@ -274,7 +274,11 @@ def get_signature(js: str, ciphered_signature: str) -> str:
274
  name, argument = parse_function(js_func)
275
  signature = transform_map[name](signature, argument)
276
  logger.debug(
277
- "applied transform function\noutput: %s\njs_function: %s\nargument: %d\nfunction: %s",
 
 
 
 
278
  "".join(signature),
279
  name,
280
  argument,
 
274
  name, argument = parse_function(js_func)
275
  signature = transform_map[name](signature, argument)
276
  logger.debug(
277
+ "applied transform function\n"
278
+ "output: %s\n"
279
+ "js_function: %s\n"
280
+ "argument: %d\n"
281
+ "function: %s",
282
  "".join(signature),
283
  name,
284
  argument,
tests/test_main.py CHANGED
@@ -10,3 +10,10 @@ def test_prefetch_deferred(MockYouTube):
10
  instance.prefetch_descramble.return_value = None
11
  YouTube("https://www.youtube.com/watch?v=9bZkp7q19f0", True)
12
  assert not instance.prefetch_descramble.called
 
 
 
 
 
 
 
 
10
  instance.prefetch_descramble.return_value = None
11
  YouTube("https://www.youtube.com/watch?v=9bZkp7q19f0", True)
12
  assert not instance.prefetch_descramble.called
13
+
14
+
15
+ @mock.patch("urllib.request.install_opener")
16
+ def test_install_proxy(opener):
17
+ proxies = {'http': 'http://www.example.com:3128/'}
18
+ YouTube("https://www.youtube.com/watch?v=9bZkp7q19f0", defer_prefetch_init=True, proxies=proxies)
19
+ opener.assert_called()
tests/test_streams.py CHANGED
@@ -125,23 +125,27 @@ 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 = '<Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2" progressive="False" type="audio">'
 
129
  assert stream == expected
130
 
131
 
132
  def test_repr_for_video_streams(cipher_signature):
133
  stream = str(cipher_signature.streams.filter(only_video=True).first())
134
- expected = '<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028" progressive="False" type="video">'
 
135
  assert stream == expected
136
 
137
 
138
  def test_repr_for_progressive_streams(cipher_signature):
139
  stream = str(cipher_signature.streams.filter(progressive=True).first())
140
- expected = '<Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2" progressive="True" type="video">'
 
141
  assert stream == expected
142
 
143
 
144
  def test_repr_for_adaptive_streams(cipher_signature):
145
  stream = str(cipher_signature.streams.filter(adaptive=True).first())
146
- expected = '<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028" progressive="False" type="video">'
 
147
  assert stream == expected
 
125
 
126
  def test_repr_for_audio_streams(cipher_signature):
127
  stream = str(cipher_signature.streams.filter(only_audio=True).first())
128
+ expected = '<Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2" ' \
129
+ 'progressive="False" type="audio">'
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 = '<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028" ' \
136
+ 'progressive="False" type="video">'
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 = '<Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" ' \
143
+ 'acodec="mp4a.40.2" progressive="True" type="video">'
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 = '<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028" ' \
150
+ 'progressive="False" type="video">'
151
  assert stream == expected