File: conftest.py

package info (click to toggle)
streamlink 8.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,568 kB
  • sloc: python: 51,299; sh: 184; makefile: 152
file content (18 lines) | stat: -rw-r--r-- 689 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from unittest.mock import ANY, AsyncMock, call

import pytest

from tests.webbrowser.cdp import FakeWebsocketConnection


@pytest.fixture()
def websocket_connection(monkeypatch: pytest.MonkeyPatch):
    fake_websocket_connection = FakeWebsocketConnection()
    mock_connect_websocket_url = AsyncMock(return_value=fake_websocket_connection)
    monkeypatch.setattr("streamlink.webbrowser.cdp.connection.connect_websocket_url", mock_connect_websocket_url)

    try:
        yield fake_websocket_connection
    finally:
        assert fake_websocket_connection.closed
        assert mock_connect_websocket_url.call_args_list == [call(ANY, "ws://localhost:1234/fake", max_message_size=2**24)]