Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ coverage.xml
/local
__pycache__/
.ruff_cache/
.venv/

/pip-wheel-metadata
# IntelliJ Idea family of suites
Expand Down
1 change: 1 addition & 0 deletions changes/2383.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed E501 (line too long) violations in the `tests/integrations/` and `tests/platforms/` directories.
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,11 @@ known-third-party = ["build"]
# debugger module *needs* to have debugpy trace imports.
"debugger/src/briefcase_debugger/debugpy.py" = ["T100"]
"debugger/tests/test_debugpy.py" = ["T100"]

# A standalone maintenance script, not part of the briefcase package; it
# *needs* to print its output for a maintainer to read.
"scripts/update_template_hashes.py" = ["T201"]
# E501: line too long, to be fixed in future changes
"tests/integrations/*" = ["E501"]
"tests/platforms/*" = ["E501"]

# PERF402: list copies, to be fixed in future changes
"tests/commands/run/test_LogFilter.py" = ["PERF402"]
"tests/platforms/macOS/test_XcodeBuildFilter.py" = ["PERF402"]
Expand Down
4 changes: 3 additions & 1 deletion tests/integrations/android_sdk/ADB/test_install_apk.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def test_install_failure_update_incompatible(adb, capsys):
side_effect=subprocess.CalledProcessError(
returncode=1,
cmd="install",
output="Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: signatures do not match]",
output=(
"Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: signatures do not match]"
),
)
)

Expand Down
13 changes: 6 additions & 7 deletions tests/integrations/android_sdk/ADB/test_run.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import subprocess
import sys
from pathlib import Path
from textwrap import dedent

import pytest

Expand Down Expand Up @@ -91,12 +90,12 @@ def test_error_handling(mock_tools, adb, name, exception, tmp_path):

def test_older_sdk_error(mock_tools, adb):
"""Failure [INSTALL_FAILED_OLDER_SDK] needs to be caught manually."""
mock_tools.subprocess.check_output.return_value = dedent(
"""\
Performing Push Install
C:/.../app-debug.apk: 1 file pushed, 0 skipped. 5.5 MB/s (33125287 bytes in 5.768s)
pkg: /data/local/tmp/app-debug.apk
Failure [INSTALL_FAILED_OLDER_SDK]"""
mock_tools.subprocess.check_output.return_value = (
"Performing Push Install\n"
"C:/.../app-debug.apk: 1 file pushed, 0 skipped. 5.5 MB/s "
"(33125287 bytes in 5.768s)\n"
" pkg: /data/local/tmp/app-debug.apk\n"
"Failure [INSTALL_FAILED_OLDER_SDK]"
)
with pytest.raises(
BriefcaseCommandError,
Expand Down
5 changes: 4 additions & 1 deletion tests/integrations/android_sdk/ADB/test_start_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ def test_unable_to_start(adb):

with pytest.raises(
BriefcaseCommandError,
match=r"Unable to start com.example.sample.package/com.example.sample.activity on exampleDevice",
match=(
r"Unable to start com.example.sample.package/"
r"com.example.sample.activity on exampleDevice"
),
):
adb.start_app(
"com.example.sample.package", "com.example.sample.activity", [], {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import subprocess
from textwrap import dedent

import pytest

Expand All @@ -8,13 +9,13 @@
def test_list_installed_system_images(mock_tools, android_sdk):
"""Returns a set of installed system image package identifiers."""

mock_tools.subprocess.check_output.return_value = (
"Installed packages:\n"
" Path | Version | Description | Location\n"
" ------- | ------- | ------- | -------\n"
" system-images;android-31;default;x86_64 | 5 | Intel x86_64 Atom System Image | system-images/android-31/default/x86_64\n"
" emulator | 35.4.9 | Android Emulator | emulator\n"
)
mock_tools.subprocess.check_output.return_value = dedent("""\
Installed packages:
Path | Version | Description | Location
------- | ------- | ------- | -------
system-images;android-31;default;x86_64 | 5 | Intel x86_64 Atom System Image | system-images/android-31/default/x86_64
emulator | 35.4.9 | Android Emulator | emulator
""") # noqa: E501

result = android_sdk.list_installed_system_images()

Expand All @@ -27,12 +28,12 @@ def test_list_installed_system_images(mock_tools, android_sdk):

def test_no_installed_system_images(mock_tools, android_sdk):
"""If no system images are installed, an empty set is returned."""
mock_tools.subprocess.check_output.return_value = (
"Installed packages:\n"
" Path | Version | Description | Location\n"
" ------- | ------- | ------- | -------\n"
" emulator | 35.4.9 | Android Emulator | emulator\n"
)
mock_tools.subprocess.check_output.return_value = dedent("""\
Installed packages:
Path | Version | Description | Location
------- | ------- | ------- | -------
emulator | 35.4.9 | Android Emulator | emulator
""") # noqa: E501

result = android_sdk.list_installed_system_images()

Expand Down
5 changes: 4 additions & 1 deletion tests/integrations/android_sdk/AndroidSDK/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ def test_bad_emulator_abi(mock_tools, android_sdk, host_os, host_arch):

with pytest.raises(
BriefcaseCommandError,
match=rf"The Android emulator does not currently support {host_os} {host_arch} hardware.",
match=(
rf"The Android emulator does not currently support {host_os} "
rf"{host_arch} hardware."
),
):
_ = android_sdk.emulator_abi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ def test_emulator_fail_to_boot(mock_tools, android_sdk):
"\n", # gets in to emulator has_booted() if block
"\n", # enters has_booted() while loop
"\n", # one loop waiting for simulator to finish booting
"1\n", # successful boot...except poll() will return non-None first raising failure
"1\n",
# successful boot...except poll() will return non-None first raising failure
]

# poll() on the process returns failure during simulator boot
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import platform
from subprocess import CalledProcessError
from textwrap import dedent

import pytest

Expand All @@ -21,7 +22,10 @@ def test_unsupported_abi(mock_tools, android_sdk, host_os, host_arch):

with pytest.raises(
BriefcaseCommandError,
match=f"The Android emulator does not currently support {host_os} {host_arch} hardware",
match=(
f"The Android emulator does not currently support {host_os} "
f"{host_arch} hardware"
),
):
android_sdk.verify_system_image("system-images;android-31;default;x86_64")

Expand Down Expand Up @@ -82,12 +86,12 @@ def test_existing_system_image(mock_tools, android_sdk):
mock_tools.host_arch = "AMD64" if platform.system() == "Windows" else "x86_64"

# Mock sdkmanager reporting the system image as installed
mock_tools.subprocess.check_output.return_value = (
"Installed packages:\n"
" Path | Version | Description | Location\n"
" ------- | ------- | ------- | -------\n"
" system-images;android-31;default;x86_64 | 5 | Intel x86_64 Atom System Image | system-images/android-31/default/x86_64\n"
)
mock_tools.subprocess.check_output.return_value = dedent("""\
Installed packages:
Path | Version | Description | Location
------- | ------- | ------- | -------
system-images;android-31;default;x86_64 | 5 | Intel x86_64 Atom System Image | system-images/android-31/default/x86_64
""") # noqa: E501

# Verify the system image that we already have
android_sdk.verify_system_image("system-images;android-31;default;x86_64")
Expand Down Expand Up @@ -130,7 +134,10 @@ def test_problem_downloading_system_image(mock_tools, android_sdk):
# Attempt to verify the system image
with pytest.raises(
BriefcaseCommandError,
match=r"Error while installing the 'system-images;android-31;default;x86_64' Android system image\.",
match=(
r"Error while installing the "
r"'system-images;android-31;default;x86_64' Android system image\."
),
):
android_sdk.verify_system_image("system-images;android-31;default;x86_64")

Expand Down
3 changes: 2 additions & 1 deletion tests/integrations/base/test_ToolCache.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def test_toolcache_typing():
"""Tool typing for ToolCache is correct."""
# Tools that are intentionally not annotated in ToolCache.
tools_unannotated = {"cookiecutter"}
# Tool names to exclude from the dynamic annotation checks; they are manually checked.
# Tool names to exclude from the dynamic annotation checks;
# they are manually checked.
tool_names_skip_dynamic_check = {
"app_context", # Tested by the Docker module
"git", # An external API, not a Briefcase Tool
Expand Down
3 changes: 2 additions & 1 deletion tests/integrations/docker/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def mock_tools(mock_tools, tmp_path) -> ToolCache:
# Mock stdlib subprocess module
mock_tools.subprocess._subprocess = MagicMock(spec_set=subprocess)

# Reset `os` mock without `spec` so tests can run on Windows where os.getuid doesn't exist.
# Reset `os` mock without `spec`
# so tests can run on Windows where os.getuid doesn't exist.
mock_tools.os = MagicMock()
# Mock user and group IDs for docker image
mock_tools.os.getuid.return_value = "37"
Expand Down
54 changes: 31 additions & 23 deletions tests/integrations/docker/test_Docker__verify.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import subprocess
from collections import namedtuple
from pathlib import Path
from textwrap import dedent
from unittest.mock import MagicMock, call

import pytest
Expand Down Expand Up @@ -197,15 +198,16 @@ def test_docker_unknown_version(mock_tools, user_mapping_run_calls, capsys):

def test_docker_exists_but_process_lacks_permission_to_use_it(mock_tools):
"""If the docker daemon isn't running, the check fails."""
error_message = """
Client:
Debug Mode: false
error_message = dedent("""\
Client:
Debug Mode: false

Server:
ERROR: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock:
Server:
ERROR: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock:

Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/info: dial unix /var/run/docker.sock: connect: permission denied
errors pretty printing info"""
Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/info: dial unix /var/run/docker.sock: connect: permission denied
errors pretty printing info
""") # noqa: E501

mock_tools.subprocess.check_output.side_effect = [
VALID_DOCKER_VERSION,
Expand All @@ -225,21 +227,24 @@ def test_docker_exists_but_process_lacks_permission_to_use_it(mock_tools):
@pytest.mark.parametrize(
"error_message",
[
"""
Client:
Debug Mode: false

Server:
ERROR: Error response from daemon: dial unix docker.raw.sock: connect: connection refused
errors pretty printing info
""", # this is the error shown on mac
"""
Client:
Debug Mode: false

Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info""", # this is the error show on linux
# Mac
dedent("""\
Client:
Debug Mode: false

Server:
ERROR: Error response from daemon: dial unix docker.raw.sock: connect: connection refused
errors pretty printing info
"""), # noqa: E501
# Linux
dedent("""\
Client:
Debug Mode: false

Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info
"""), # noqa: E501
],
)
def test_docker_exists_but_is_not_running(error_message, mock_tools):
Expand Down Expand Up @@ -290,7 +295,10 @@ def test_buildx_plugin_not_installed(mock_tools):

with pytest.raises(
BriefcaseCommandError,
match="Docker is installed and available for use but the buildx plugin\nis not installed",
match=(
"Docker is installed and available for use but the buildx plugin\n"
"is not installed"
),
):
Docker.verify(mock_tools)

Expand Down
16 changes: 11 additions & 5 deletions tests/integrations/docker/test_Docker__x11_passthrough.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def test_x11_is_display_tcp(
("is_socket_outcomes", "is_tcp_outcomes", "expected_display_num"),
[
([False], [False], 50),
# Due to short-circuiting, only the first iterator is consumed if it returns False
# Due to short-circuiting, only the first
# iterator is consumed if it returns False
([True, False], [False], 51),
([True, True, False, True, False], [False, False, False], 52),
([True] * 248 + [False, False], [True, False], 299),
Expand Down Expand Up @@ -365,9 +366,11 @@ def test_x11_write_xauth_success(mock_tools, tmp_path, sub_check_output_kw):
"-",
],
input=(
"ffff 0007 6a757069746572 0000 0012 4d49542d4d414749432d434f4f4b49452d31 "
"ffff 0007 6a757069746572 0000 0012 "
"4d49542d4d414749432d434f4f4b49452d31 "
"0010 fa4b61837675f1581427e0c937701439\n"
"ffff 0007 6a757069746572 0000 0012 4d49542d4d414749432d434f4f4b49452d31 "
"ffff 0007 6a757069746572 0000 0012 "
"4d49542d4d414749432d434f4f4b49452d31 "
"0010 fa4b61837675f1581427e0c937701439"
),
**sub_check_output_kw,
Expand Down Expand Up @@ -477,7 +480,9 @@ def test_x11_passthrough_missing_DISPLAY(mock_tools, DISPLAY):
with (
pytest.raises(
BriefcaseCommandError,
match="The DISPLAY environment variable must be set to run an app in Docker",
match=(
"The DISPLAY environment variable must be set to run an app in Docker"
),
),
mock_tools.docker.x11_passthrough({}),
):
Expand Down Expand Up @@ -594,7 +599,8 @@ def test_x11_passthrough_xauth_fails(mock_tools, in_kwargs, out_kwargs, capsys):
assert capsys.readouterr().out == (
"An X11 authentication database could not be created for the display.\n"
"\n"
"Briefcase will proceed, but if access to the display is rejected, this may be why.\n"
"Briefcase will proceed, but if access to the display "
"is rejected, this may be why.\n"
)


Expand Down
3 changes: 2 additions & 1 deletion tests/integrations/file/test_File__download.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ def test_connection_error(mock_tools):
# Keep using the fixture though, so that it still gets cleaned up after the test
mock_tools.httpx = mock.Mock(wraps=httpx)

# Failure leads to filename never being read, so the error message will use the full URL
# Failure leads to filename never being read,
# so the error message will use the full URL
# rather than the filename
with pytest.raises(NetworkFailure, match=f"Unable to download {url}"):
mock_tools.file.download(
Expand Down
3 changes: 2 additions & 1 deletion tests/integrations/file/test_File__sorted_depth_first.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
["foo/bar/a.txt", "foo/bar/c.txt", "foo/bar/b.txt"],
["foo/bar/c.txt", "foo/bar/b.txt", "foo/bar/a.txt"],
),
# Subfolders are sorted before files in that directory; but sorted lexically in themselves
# Subfolders are sorted before files in that directory;
# but sorted lexically in themselves
(
[
"foo/bar/b",
Expand Down
10 changes: 8 additions & 2 deletions tests/integrations/flatpak/test_Flatpak__verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ def test_flatpak_not_installed(mock_tools):

with pytest.raises(
BriefcaseCommandError,
match=r"Briefcase requires the Flatpak toolchain, but it does not appear to be installed.",
match=(
r"Briefcase requires the Flatpak toolchain, "
r"but it does not appear to be installed."
),
):
Flatpak.verify(mock_tools)

Expand Down Expand Up @@ -98,7 +101,10 @@ def test_flatpak_builder_not_installed(mock_tools):

with pytest.raises(
BriefcaseCommandError,
match=r"Briefcase requires the full Flatpak development toolchain, but flatpak-builder",
match=(
r"Briefcase requires the full Flatpak development toolchain, "
r"but flatpak-builder"
),
):
Flatpak.verify(mock_tools)

Expand Down
5 changes: 4 additions & 1 deletion tests/integrations/flatpak/test_Flatpak__verify_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def test_verify_repo_fail(flatpak):

with pytest.raises(
BriefcaseCommandError,
match=r"Unable to add Flatpak repo https://example.com/flatpak with alias test-alias.",
match=(
r"Unable to add Flatpak repo "
r"https://example.com/flatpak with alias test-alias."
),
):
flatpak.verify_repo(
repo_alias="test-alias",
Expand Down
Loading