File: test_version_check.py

package info (click to toggle)
streamlink 8.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,564 kB
  • sloc: python: 51,188; sh: 184; makefile: 152
file content (42 lines) | stat: -rw-r--r-- 1,094 bytes parent folder | download | duplicates (4)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from unittest.mock import Mock

import pytest

import streamlink_cli.main


@pytest.mark.parametrize(
    ("argv", "latest", "aborted", "exit_code"),
    [
        pytest.param(
            ["--version-check"],
            True,
            True,
            130,
            id="aborted",
        ),
        pytest.param(
            ["--version-check"],
            True,
            False,
            0,
            id="latest",
        ),
        pytest.param(
            ["--version-check"],
            False,
            False,
            1,
            id="outdated",
        ),
    ],
    indirect=["argv"],
)
def test_version_check(monkeypatch: pytest.MonkeyPatch, argv: list, latest: bool, aborted: bool, exit_code: int):
    mock_check_version = Mock(return_value=latest, side_effect=KeyboardInterrupt if aborted else None)
    monkeypatch.setattr("streamlink_cli.main.check_version", mock_check_version)

    with pytest.raises(SystemExit) as exc_info:
        streamlink_cli.main.main()
    assert exc_info.value.code == exit_code
    assert mock_check_version.call_count == 1