File: test_NativeAppContext__verify.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-- 1,237 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 pytest

from briefcase.exceptions import UnsupportedHostError
from briefcase.integrations.subprocess import NativeAppContext, Subprocess


def test_short_circuit(mock_tools, first_app_config):
    """Tool is not created if already cached."""
    mock_tools[first_app_config].app_context = "tool"

    tool = NativeAppContext.verify(mock_tools, first_app_config)

    assert tool == "tool"
    assert tool == mock_tools[first_app_config].app_context


def test_unsupported_os(mock_tools):
    """When host OS is not supported, an error is raised."""
    mock_tools.host_os = "wonky"

    with pytest.raises(
        UnsupportedHostError,
        match=f"{NativeAppContext.name} is not supported on wonky",
    ):
        NativeAppContext.verify(mock_tools, app=object())


def test_verify(mock_tools, first_app_config):
    """Subprocess verify always returns/sets subprocess tool."""
    native_app_context_tool = NativeAppContext.verify(mock_tools, first_app_config)

    assert isinstance(native_app_context_tool, Subprocess)
    assert native_app_context_tool is mock_tools[first_app_config].app_context
    # native app context should be the default subprocess tool
    assert native_app_context_tool is mock_tools.subprocess