File: test_stream_file.py

package info (click to toggle)
streamlink 1.0.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,588 kB
  • sloc: python: 31,121; makefile: 141; sh: 93
file content (27 lines) | stat: -rw-r--r-- 729 bytes parent folder | download
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
26
27
import unittest

from streamlink.stream.file import FileStream

try:
    from unittest.mock import Mock, patch, mock_open
except ImportError:
    from mock import Mock, patch, mock_open

from streamlink import Streamlink


class TestFileStream(unittest.TestCase):
    def setUp(self):
        self.session = Streamlink()

    def test_open_file_path(self):
        m = mock_open()
        s = FileStream(self.session, path="/test/path")
        with patch('streamlink.stream.file.open', m, create=True):
            s.open()
            m.assert_called_with("/test/path")

    def test_open_fileobj(self):
        fileobj = Mock()
        s = FileStream(self.session, fileobj=fileobj)
        self.assertEqual(fileobj, s.open())