File: test_emulators.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 (39 lines) | stat: -rw-r--r-- 1,187 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
36
37
38
39
import subprocess

import pytest

from briefcase.exceptions import BriefcaseCommandError


@pytest.mark.parametrize(
    "output, expected_list",
    [
        ("", []),
        ("first\n", ["first"]),
        ("first\nsecond\nthird\n", ["first", "second", "third"]),
        ("first\n\nsecond", ["first", "second"]),
        (
            "first\nINFO    | Storing crashdata in\nsecond\nWARNING | nothing to see\n"
            "third\nERROR   | lot to see here",
            ["first", "second", "third"],
        ),
    ],
)
def test_no_emulators(mock_tools, android_sdk, output, expected_list):
    """The returned list of emulators is properly parsed."""
    mock_tools.subprocess.check_output.return_value = output

    assert android_sdk.emulators() == expected_list


def test_emulator_error(mock_tools, android_sdk):
    """If there is a problem invoking emulator, an error is returned."""
    mock_tools.subprocess.check_output.side_effect = subprocess.CalledProcessError(
        returncode=69, cmd="emulator -list-avd"
    )

    with pytest.raises(
        BriefcaseCommandError,
        match=r"Unable to obtain Android emulator list",
    ):
        android_sdk.emulators()