hbmartin commited on
Commit
9172cb2
·
1 Parent(s): c8a7d8e

added test_get_highest_resolution

Browse files
Files changed (3) hide show
  1. pytube/query.py +1 -6
  2. tests/test_helpers.py +16 -0
  3. tests/test_query.py +4 -1
pytube/query.py CHANGED
@@ -282,12 +282,7 @@ class StreamQuery:
282
  not found.
283
 
284
  """
285
- return (
286
- self.filter(progressive=True)
287
- .order_by("resolution")
288
- .asc()
289
- .last()
290
- )
291
 
292
  def first(self) -> Optional[Stream]:
293
  """Get the first :class:`Stream <Stream>` in the results.
 
282
  not found.
283
 
284
  """
285
+ return self.filter(progressive=True).order_by("resolution").asc().last()
 
 
 
 
 
286
 
287
  def first(self) -> Optional[Stream]:
288
  """Get the first :class:`Stream <Stream>` in the results.
tests/test_helpers.py CHANGED
@@ -1,8 +1,11 @@
1
  # -*- coding: utf-8 -*-
 
 
2
  import pytest
3
 
4
  from pytube import helpers
5
  from pytube.exceptions import RegexMatchError
 
6
 
7
 
8
  def test_regex_search_no_match():
@@ -18,3 +21,16 @@ def test_safe_filename():
18
  """Unsafe characters get stripped from generated filename"""
19
  assert helpers.safe_filename("abc1245$$") == "abc1245"
20
  assert helpers.safe_filename("abc##") == "abc"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # -*- coding: utf-8 -*-
2
+ from unittest import mock
3
+
4
  import pytest
5
 
6
  from pytube import helpers
7
  from pytube.exceptions import RegexMatchError
8
+ from pytube.helpers import deprecated
9
 
10
 
11
  def test_regex_search_no_match():
 
21
  """Unsafe characters get stripped from generated filename"""
22
  assert helpers.safe_filename("abc1245$$") == "abc1245"
23
  assert helpers.safe_filename("abc##") == "abc"
24
+
25
+
26
+ @mock.patch("warnings.warn")
27
+ def test_deprecated(warn):
28
+ @deprecated("oh no")
29
+ def deprecated_function():
30
+ return None
31
+ deprecated_function()
32
+ warn.assert_called_with(
33
+ "Call to deprecated function deprecated_function (oh no).",
34
+ category=DeprecationWarning,
35
+ stacklevel=2,
36
+ )
tests/test_query.py CHANGED
@@ -132,7 +132,6 @@ def test_get_by_itag(cipher_signature):
132
  :class:`Stream <Stream>`.
133
  """
134
  assert cipher_signature.streams.get_by_itag(18).itag == 18
135
- assert cipher_signature.streams.get_by_itag("18").itag == 18
136
 
137
 
138
  def test_get_by_non_existent_itag(cipher_signature):
@@ -147,6 +146,10 @@ def test_get_lowest_resolution(cipher_signature):
147
  assert cipher_signature.streams.get_lowest_resolution().itag == 18
148
 
149
 
 
 
 
 
150
  def test_filter_is_dash(cipher_signature):
151
  streams = cipher_signature.streams.filter(is_dash=False).all()
152
  itags = [s.itag for s in streams]
 
132
  :class:`Stream <Stream>`.
133
  """
134
  assert cipher_signature.streams.get_by_itag(18).itag == 18
 
135
 
136
 
137
  def test_get_by_non_existent_itag(cipher_signature):
 
146
  assert cipher_signature.streams.get_lowest_resolution().itag == 18
147
 
148
 
149
+ def test_get_highest_resolution(cipher_signature):
150
+ assert cipher_signature.streams.get_highest_resolution().itag == 18
151
+
152
+
153
  def test_filter_is_dash(cipher_signature):
154
  streams = cipher_signature.streams.filter(is_dash=False).all()
155
  itags = [s.itag for s in streams]