test_launch.py
This file
Path
tests/test_launch.py
56 lines · 1.4 KiB · Python
Last changed by
➖ Drop support for Python 3.8 (#1464)Sebastián Ramírezbefore adoptionfbff83e
History of this fileTake it
The walk stopped after 200 commits: lines older than 324c3ce point at it.
🔧 Configure reminder for `waiting` label in `issue-manager` (#1378)Motov Yuriibefore adoption324c3ce
lines 1–18why, one step back1import subprocess2from unittest.mock import patch34import pytest5import typer67url = "http://example.com"8910@pytest.mark.parametrize(11 "system, command",12 [13 ("Darwin", "open"),14 ("Linux", "xdg-open"),15 ("FreeBSD", "xdg-open"),16 ],17)18def test_launch_url_unix(system: str, command: str):➖ Drop support for Python 3.8 (#1464)Sebastián Ramírezbefore adoptionfbff83e
lines 19–23why, one step back19 with (20 patch("platform.system", return_value=system),21 patch("shutil.which", return_value=True),22 patch("subprocess.Popen") as mock_popen,23 ):🔧 Configure reminder for `waiting` label in `issue-manager` (#1378)Motov Yuriibefore adoption324c3ce
lines 24–31why, one step back24 typer.launch(url)2526 mock_popen.assert_called_once_with(27 [command, url], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT28 )293031def test_launch_url_windows():➖ Drop support for Python 3.8 (#1464)Sebastián Ramírezbefore adoptionfbff83e
lines 32–35why, one step back32 with (33 patch("platform.system", return_value="Windows"),34 patch("webbrowser.open") as mock_webbrowser_open,35 ):🔧 Configure reminder for `waiting` label in `issue-manager` (#1378)Motov Yuriibefore adoption324c3ce
lines 36–41why, one step back36 typer.launch(url)3738 mock_webbrowser_open.assert_called_once_with(url)394041def test_launch_url_no_xdg_open():➖ Drop support for Python 3.8 (#1464)Sebastián Ramírezbefore adoptionfbff83e
lines 42–46why, one step back42 with (43 patch("platform.system", return_value="Linux"),44 patch("shutil.which", return_value=None),45 patch("webbrowser.open") as mock_webbrowser_open,46 ):🔧 Configure reminder for `waiting` label in `issue-manager` (#1378)Motov Yuriibefore adoption324c3ce
lines 47–56why, one step back47 typer.launch(url)4849 mock_webbrowser_open.assert_called_once_with(url)505152def test_calls_original_launch_when_not_passing_urls():53 with patch("typer.main.click.launch", return_value=0) as launch_mock:54 typer.launch("not a url")5556 launch_mock.assert_called_once_with("not a url")