File size: 586 Bytes
22b0f22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import mock
import pytest

from pytube import api


@pytest.fixture
def yt_video():
    url = 'http://www.youtube.com/watch?v=9bZkp7q19f0'
    mock_html = None
    mock_js = None

    with open('tests/mock_data/youtube_gangnam_style.html') as fh:
        mock_html = fh.read()

    with open('tests/mock_data/youtube_gangnam_style.js') as fh:
        mock_js = fh.read()

    with mock.patch('pytube.api.urlopen') as urlopen:
        urlopen.return_value.read.return_value = mock_html
        yt = api.YouTube()
        yt._js_cache = mock_js
        yt.from_url(url)
        return yt