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
|
import subprocess
from unittest.mock import MagicMock
import pytest
from briefcase.exceptions import BriefcaseCommandError
def test_kill(mock_tools, adb):
"""An emulator can be killed."""
# Invoke kill
adb.kill()
# Validate call parameters.
mock_tools.subprocess.check_output.assert_called_once_with(
[
mock_tools.android_sdk.adb_path,
"-s",
"exampleDevice",
"emu",
"kill",
],
quiet=False,
)
def test_kill_failure(adb):
"""If emu kill fails, the error is caught."""
# Mock out the run command on an adb instance
adb.run = MagicMock(
side_effect=subprocess.CalledProcessError(returncode=1, cmd="adb emu kill")
)
with pytest.raises(BriefcaseCommandError):
adb.kill()
|