Debian Codegraph @

tests/integrations/subprocess/test_Subprocess__verify.py

raw
1 import pytest
2
3 from briefcase.exceptions import UnsupportedHostError
4 from briefcase.integrations.subprocess import Subprocess
5
6
7 def test_short_circuit(mock_tools):
8 """Tool is not created if already cached."""
9 mock_tools.subprocess = "tool"
10
11 tool = Subprocess.verify(mock_tools)
12
13 assert tool == "tool"
14 assert tool == mock_tools.subprocess
15
16
17 def test_unsupported_os(mock_tools):
18 """When host OS is not supported, an error is raised."""
19 mock_tools.host_os = "wonky"
20
21 # Delete subprocess since it has already been verified
22 delattr(mock_tools, "subprocess")
23
24 with pytest.raises(
25 UnsupportedHostError,
26 match=f"{Subprocess.name} is not supported on wonky",
27 ):
28 Subprocess.verify(mock_tools)
29
30
31 def test_verify(mock_tools):
32 """Subprocess verify always returns/sets subprocess tool."""
33 subprocess_tool = Subprocess.verify(mock_tools)
34 assert isinstance(subprocess_tool, Subprocess)
35 assert subprocess_tool is mock_tools.subprocess