Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_appargs_doubledash(
pipx_temp_env, capsys, monkeypatch, input_run_args, expected_app_with_args
):
parser = pipx.main.get_command_parser()
monkeypatch.setattr(sys, "argv", ["pipx", "run"] + input_run_args)
parsed_pipx_args = parser.parse_args()
pipx.main.check_args(parsed_pipx_args)
assert parsed_pipx_args.app_with_args == expected_app_with_args
def run_pipx_cli(pipx_args: List[str]):
with mock.patch.object(sys, "argv", ["pipx"] + pipx_args):
return main.cli()
def test_version(monkeypatch, capsys):
mock_exit = mock.Mock(side_effect=ValueError("raised in test to exit early"))
with mock.patch.object(sys, "exit", mock_exit), pytest.raises(
ValueError, match="raised in test to exit early"
):
assert not run_pipx_cli(["--version"])
captured = capsys.readouterr()
mock_exit.assert_called_with(0)
assert main.__version__ in captured.out.strip()
def test_simple_parse_version(ver_str, expected):
assert main.simple_parse_version(ver_str) == expected
def test_appargs_doubledash(
pipx_temp_env, capsys, monkeypatch, input_run_args, expected_app_with_args
):
parser = pipx.main.get_command_parser()
monkeypatch.setattr(sys, "argv", ["pipx", "run"] + input_run_args)
parsed_pipx_args = parser.parse_args()
pipx.main.check_args(parsed_pipx_args)
assert parsed_pipx_args.app_with_args == expected_app_with_args