added exception test
Browse files- pytube/query.py +2 -2
- tests/test_exceptions.py +9 -1
pytube/query.py
CHANGED
@@ -334,8 +334,8 @@ class StreamQuery(Sequence):
|
|
334 |
"""
|
335 |
if value:
|
336 |
return self.fmt_streams.count(value)
|
337 |
-
|
338 |
-
|
339 |
|
340 |
@deprecated("This object can be treated as a list, all() is useless")
|
341 |
def all(self) -> List[Stream]: # pragma: no cover
|
|
|
334 |
"""
|
335 |
if value:
|
336 |
return self.fmt_streams.count(value)
|
337 |
+
|
338 |
+
return len(self)
|
339 |
|
340 |
@deprecated("This object can be treated as a list, all() is useless")
|
341 |
def all(self) -> List[Stream]: # pragma: no cover
|
tests/test_exceptions.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
# -*- coding: utf-8 -*-
|
2 |
-
from pytube.exceptions import VideoUnavailable, RegexMatchError
|
3 |
|
4 |
|
5 |
def test_video_unavailable():
|
@@ -15,3 +15,11 @@ def test_regex_match_error():
|
|
15 |
raise RegexMatchError(caller="hello", pattern="*")
|
16 |
except RegexMatchError as e:
|
17 |
assert str(e) == "hello: could not find match for *"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# -*- coding: utf-8 -*-
|
2 |
+
from pytube.exceptions import VideoUnavailable, RegexMatchError, LiveStreamError
|
3 |
|
4 |
|
5 |
def test_video_unavailable():
|
|
|
15 |
raise RegexMatchError(caller="hello", pattern="*")
|
16 |
except RegexMatchError as e:
|
17 |
assert str(e) == "hello: could not find match for *"
|
18 |
+
|
19 |
+
|
20 |
+
def test_live_stream_error():
|
21 |
+
try:
|
22 |
+
raise LiveStreamError(video_id="YLnZklYFe7E")
|
23 |
+
except LiveStreamError as e:
|
24 |
+
assert e.video_id == "YLnZklYFe7E"
|
25 |
+
assert str(e) == "YLnZklYFe7E is streaming live and cannot be loaded"
|