unit tests
Browse files- pytube/extract.py +1 -1
- tests/requirements.txt +1 -0
- tests/test_extract.py +20 -0
pytube/extract.py
CHANGED
@@ -20,7 +20,7 @@ def video_id(url):
|
|
20 |
|
21 |
def watch_url(video_id):
|
22 |
return (
|
23 |
-
'
|
24 |
.format(video_id=video_id)
|
25 |
)
|
26 |
|
|
|
20 |
|
21 |
def watch_url(video_id):
|
22 |
return (
|
23 |
+
'https://www.youtube.com/watch?v={video_id}'
|
24 |
.format(video_id=video_id)
|
25 |
)
|
26 |
|
tests/requirements.txt
CHANGED
@@ -5,3 +5,4 @@ mock==1.3.0
|
|
5 |
pre-commit==0.15.0
|
6 |
pytest==3.1.3
|
7 |
pytest-cov==2.4.0
|
|
|
|
5 |
pre-commit==0.15.0
|
6 |
pytest==3.1.3
|
7 |
pytest-cov==2.4.0
|
8 |
+
pytest-sugar==0.9.0
|
tests/test_extract.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""
|
3 |
+
tests.test_extract
|
4 |
+
~~~~~~~~~~~~~~~~~~
|
5 |
+
|
6 |
+
Unit tests for the :module:`extract <extract>` module.
|
7 |
+
"""
|
8 |
+
from pytube import extract
|
9 |
+
|
10 |
+
|
11 |
+
def test_extract_video_id():
|
12 |
+
url = 'https://www.youtube.com/watch?v=9bZkp7q19f0'
|
13 |
+
video_id = extract.video_id(url)
|
14 |
+
assert video_id == '9bZkp7q19f0'
|
15 |
+
|
16 |
+
|
17 |
+
def test_extract_watch_url():
|
18 |
+
video_id = '9bZkp7q19f0'
|
19 |
+
watch_url = extract.watch_url(video_id)
|
20 |
+
assert watch_url == 'https://www.youtube.com/watch?v=9bZkp7q19f0'
|