File: test_kill.py

package info (click to toggle)
python-briefcase 0.3.22-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,300 kB
  • sloc: python: 59,405; makefile: 57
file content (35 lines) | stat: -rw-r--r-- 817 bytes parent folder | download | duplicates (2)
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()