File: test_launch.py

package info (click to toggle)
pybrowsers 0.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 216 kB
  • sloc: python: 375; makefile: 32
file content (38 lines) | stat: -rw-r--r-- 1,177 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
28
29
30
31
32
33
34
35
36
37
38
import sys
from unittest import mock

import pytest

import browsers


@pytest.mark.parametrize(
    "browser_path",
    (
        pytest.param(
            "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
            id="osx",
            marks=pytest.mark.skipif(sys.platform != "darwin", reason="osx-only"),
        ),
        pytest.param(
            "/usr/lib/firefox-esr/firefox-esr",
            id="linux",
            marks=pytest.mark.skipif(sys.platform != "linux", reason="linux-only"),
        ),
        pytest.param(
            r"C:\Program Files\Google\Chrome\Application\chrome.exe",
            id="windows",
            marks=pytest.mark.skipif(sys.platform != "win32", reason="windows-only"),
        ),
    ),
)
@mock.patch.object(browsers, "_launch")
def test_launch(mock_launch: mock.MagicMock, browser_path: str) -> None:
    browsers.launch("firefox", url="localhost")
    mock_launch.assert_called_with("firefox", browser_path, [], "localhost")


@mock.patch.object(browsers, "_launch")
def test_launch_no_browser(mock_launch: mock.MagicMock) -> None:
    browsers.launch("hello", url="localhost")
    mock_launch.assert_not_called()