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
|
import subprocess
import sys
from unittest import mock
import pytest
from briefcase.integrations.subprocess import Subprocess
from briefcase.platforms.linux.system import LinuxSystemDevCommand
@pytest.fixture
def dev_command(dummy_console, tmp_path):
command = LinuxSystemDevCommand(
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_flatpak_dev_starts(dev_command, first_app_config, tmp_path):
"""A Flatpak app can be started in development mode using Python."""
log_popen = mock.MagicMock()
dev_command.tools.subprocess.Popen.return_value = log_popen
dev_command.run_dev_app(first_app_config, env={}, passthrough=[])
popen_args, popen_kwargs = dev_command.tools.subprocess.Popen.call_args
# Check that Python executable is used
assert popen_args[0][0] == sys.executable
assert "run_module" in popen_args[0][2]
assert first_app_config.module_name in popen_args[0][2]
# Validate subprocess settings
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
dev_command._stream_app_logs.assert_called_once_with(
first_app_config, popen=log_popen, clean_output=False
)
|