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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
import subprocess
import sys
from unittest import mock
import pytest
from briefcase.integrations.subprocess import Subprocess
from briefcase.platforms.windows.visualstudio import WindowsVisualStudioDevCommand
@pytest.fixture
def dev_command(dummy_console, tmp_path):
command = WindowsVisualStudioDevCommand(
console=dummy_console,
base_path=tmp_path / "base_path",
data_path=tmp_path / "briefcase",
)
command.tools.home_path = tmp_path / "home"
command.tools.subprocess = mock.MagicMock(spec_set=Subprocess)
command._stream_app_logs = mock.MagicMock()
return command
def test_dev_visualstudio_app_starts(dev_command, first_app_config, tmp_path):
"""A Windows Visual Studio app can be started in development mode using Python."""
log_popen = mock.MagicMock()
dev_command.tools.subprocess.Popen.return_value = log_popen
# Run the dev command
dev_command.run_dev_app(first_app_config, env={}, passthrough=[])
# Extract the actual Popen call arguments
popen_args, popen_kwargs = dev_command.tools.subprocess.Popen.call_args
# Verify that Python is used
assert popen_args[0][0] == sys.executable
# Check that the app's module name is in the run command
assert "run_module" in popen_args[0][2]
assert first_app_config.module_name in popen_args[0][2]
# Common subprocess parameters
assert popen_kwargs["cwd"] == tmp_path / "home"
assert popen_kwargs["encoding"] == "UTF-8"
assert popen_kwargs["stdout"] == subprocess.PIPE
assert popen_kwargs["stderr"] == subprocess.STDOUT
assert popen_kwargs["bufsize"] == 1
# Verify log streaming
dev_command._stream_app_logs.assert_called_once_with(
first_app_config,
popen=log_popen,
clean_output=False,
)
|