Skip to content
Merged
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 changes/2688.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
E501 linting issues have been resolved for the tests/commands, tests/config and tests/console folder
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ ignore = [

[tool.ruff.lint.per-file-ignores]
# E501: line too long, to be fixed in future changes
"tests/*" = ["E501"]
"src/briefcase/bootstraps/*" = ["E501"]
"tests/integrations/*" = ["E501"]
"tests/platforms/*" = ["E501"]


[tool.rumdl]
Expand Down
6 changes: 4 additions & 2 deletions tests/commands/base/test_finalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def test_finalize_single(base_command, first_app, second_app):


def test_finalize_all_repeat(base_command, first_app, second_app):
"Multiple calls to finalize verifies host & tools multiple times, but only once on config"
"""Multiple calls to finalize verifies host & tools multiple times, but only once on
"config."""
# Finalize apps twice. This is an approximation of what happens
# when a command chain is executed; create, update, build and run will
# all finalize; create will finalize the app configs, each command will
Expand Down Expand Up @@ -113,7 +114,8 @@ def test_finalize_all_repeat(base_command, first_app, second_app):


def test_finalize_single_repeat(base_command, first_app, second_app):
"Multiple calls to finalize verifies host & tools multiple times, but finalizes app config once"
"""Multiple calls to finalize verifies host & tools multiple times, but finalizes
app "config once."""

# Finalize app twice. This is an approximation of what happens
# when a command chain is executed; create, update, build and run will
Expand Down
4 changes: 3 additions & 1 deletion tests/commands/base/test_parse_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def test_incomplete_global_config(base_command):

with pytest.raises(
BriefcaseConfigError,
match=r"Global configuration is incomplete \(missing 'bundle', 'project_name'\)",
match=(
r"Global configuration is incomplete \(missing 'bundle', 'project_name'\)"
),
):
base_command.parse_config(filename, {})

Expand Down
5 changes: 4 additions & 1 deletion tests/commands/base/test_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ def raise_calledprpcesserror(*a, **kw):

with pytest.raises(
BriefcaseCommandError,
match=r"Failed to create the Briefcase directory to store tools and support files:",
match=(
r"Failed to create the Briefcase directory to store tools and support"
r" files:"
),
):
DummyCommand(console=dummy_console, data_path=data_path)

Expand Down
31 changes: 21 additions & 10 deletions tests/commands/base/test_update_cookiecutter_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def test_new_repo_template_mkdir_interrupt(base_command, mock_git):
"""A really early interrupt will occur before the template dir is created."""
base_command.tools.git = mock_git

# We don't have a convenient point to insert a KeyboardInterrupt *before* creating the
# directory, so we fake the effect - make the side effect of the clone deletion of
# the entire folder; then raise the KeyboardInterrupt.
# We don't have a convenient point to insert a KeyboardInterrupt *before* creating
# the directory, so we fake the effect - make the side effect of the clone deletion
# of the entire folder; then raise the KeyboardInterrupt.
def clone_failure(to_path, **kwargs):
shutil.rmtree(to_path)
raise KeyboardInterrupt()
Expand Down Expand Up @@ -107,7 +107,8 @@ def test_new_repo_invalid_template_url(base_command, mock_git):
with pytest.raises(
BriefcaseCommandError,
match=(
r"Unable to clone repository 'https://example.com/magic/special-template.git'"
r"Unable to clone repository"
r" 'https://example.com/magic/special-template.git'"
),
):
base_command.update_cookiecutter_cache(
Expand All @@ -131,14 +132,19 @@ def test_new_repo_invalid_template_url(base_command, mock_git):
("stderr_string", "error_message"),
[
pytest.param(
"\n stderr: '\nfatal: could not clone repository 'https://example.com' \n'",
(
"\n stderr: '\nfatal: could not clone repository"
" 'https://example.com' \n'"
),
"Could not clone repository 'https://example.com'.",
id="tailing-whitespace-no-caps-no-period",
),
pytest.param(
(
"\n stderr: '\nfatal: Could not read from remote repository.\n\n"
"Please make sure you have the correct access rights\nand the repository exists. \n'"
"\n stderr: '\nfatal: Could not read from remote repository."
"\n\nPlease"
" make sure you have the correct access rights\nand the repository"
" exists. \n'"
),
(
"Could not read from remote repository.\n\nPlease make sure "
Expand All @@ -149,7 +155,8 @@ def test_new_repo_invalid_template_url(base_command, mock_git):
pytest.param(
(
"\n stderr: '\nfatal: unable to access 'https://example.com/': "
"OpenSSL/3.2.2: error:0A000438:SSL routines::tlsv1 alert internal error'"
"OpenSSL/3.2.2: error:0A000438:SSL routines::tlsv1 alert internal "
"error'"
),
(
"Unable to access 'https://example.com/': OpenSSL/3.2.2: "
Expand Down Expand Up @@ -179,8 +186,12 @@ def test_repo_clone_error(stderr_string, error_message, base_command, mock_git):

with pytest.raises(
BriefcaseCommandError,
# The error message should not retain the "fatal:" prefix; it isn't useful information to the user.
match=f"Unable to clone repository '{re.escape(repository)}'.\n\n?(?<!fatal: ){re.escape(error_message)}",
# The error message should not retain the "fatal:" prefix; it isn't useful
# information to the user.
match=(
f"Unable to clone repository '{re.escape(repository)}'.\n\n?(?<!fatal:"
f" ){re.escape(error_message)}"
),
):
base_command.update_cookiecutter_cache(
template=repository,
Expand Down
5 changes: 4 additions & 1 deletion tests/commands/base/test_verify_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def test_platform_version_incompatible(base_command, my_app, template_version):

with pytest.raises(
BriefcaseCommandError,
match=r"The app template used to generate this app is not compatible with this version\nof Briefcase\.",
match=(
r"The app template used to generate this app is not compatible with this"
r" version\nof Briefcase\."
),
):
base_command.verify_app_template(my_app)
9 changes: 6 additions & 3 deletions tests/commands/convert/test_input_app_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def test_no_pep621_data(convert_command, monkeypatch):

mock_text_question.assert_called_once_with(
intro=PartialMatchString(
"Based on your PEP508 formatted directory name, we suggest an app name of 'test-app-name'"
"Based on your PEP508 formatted directory name, we suggest an app name of"
" 'test-app-name'"
),
description="App Name",
default="test-app-name",
Expand Down Expand Up @@ -54,7 +55,8 @@ def test_invalid_hint_app_name(convert_command, monkeypatch):

mock_text_question.assert_called_once_with(
intro=NoMatchString(
"Based on your PEP508 formatted directory name, we suggest an app name of 'test-app-name'"
"Based on your PEP508 formatted directory name, we suggest an app name of"
" 'test-app-name'"
),
description="App Name",
default="hello-world",
Expand All @@ -72,7 +74,8 @@ def test_hint_is_canonicalized(convert_command, monkeypatch):

mock_text_question.assert_called_once_with(
intro=PartialMatchString(
"Based on your PEP508 formatted directory name, we suggest an app name of 'test-app-name'"
"Based on your PEP508 formatted directory name, we suggest an app name of"
" 'test-app-name'"
),
description="App Name",
default="test-app-name",
Expand Down
10 changes: 8 additions & 2 deletions tests/commands/convert/test_input_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
# Includes some extra text to ensure it doesn't get caught as MIT because of
# perMITted
(
"Redistribution and use in source and binary forms, with or without modification, are permitted",
(
"Redistribution and use in source and binary forms, with or without"
" modification, are permitted"
),
"BSD-3-Clause",
),
("GPLv2", "GPL-2.0"),
Expand Down Expand Up @@ -76,7 +79,10 @@ def test_get_license_from_file(
# Includes some extra text to ensure it doesn't get caught as MIT because of
# perMITted
(
"Redistribution and use in source and binary forms, with or without modification, are permitted",
(
"Redistribution and use in source and binary forms, with or without"
" modification, are permitted"
),
"BSD-3-Clause",
),
("GPLv2", "GPL-2.0"),
Expand Down
20 changes: 16 additions & 4 deletions tests/commands/convert/test_input_test_source_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ def test_no_test_dir(convert_command, monkeypatch):
monkeypatch.setattr(convert_command.console, "text_question", mock_text_question)

convert_command.input_test_source_dir("app_name", None)
intro_content = "\n\nBased on your project's folder structure, we believe 'test' might be your test directory"
intro_content = (
"\n\nBased on your project's folder structure, we believe 'test' might be your"
" test directory"
)
mock_text_question.assert_called_once_with(
intro=NoMatchString(intro_content),
description="Test Source Directory",
Expand All @@ -25,7 +28,10 @@ def test_test_dir(convert_command, monkeypatch):
(convert_command.base_path / "test").mkdir()
convert_command.input_test_source_dir("app_name", None)

intro_content = "\n\nBased on your project's folder structure, we believe 'test' might be your test directory"
intro_content = (
"\n\nBased on your project's folder structure, we believe 'test' might be your"
" test directory"
)
mock_text_question.assert_called_once_with(
intro=PartialMatchString(intro_content),
description="Test Source Directory",
Expand All @@ -42,7 +48,10 @@ def test_tests_dir(convert_command, monkeypatch):
(convert_command.base_path / "tests").mkdir()
convert_command.input_test_source_dir("app_name", None)

intro_content = "\n\nBased on your project's folder structure, we believe 'tests' might be your test directory"
intro_content = (
"\n\nBased on your project's folder structure, we believe 'tests' might be your"
" test directory"
)
mock_text_question.assert_called_once_with(
intro=PartialMatchString(intro_content),
description="Test Source Directory",
Expand All @@ -60,7 +69,10 @@ def test_tests_dir_is_prefered_over_test_dir(convert_command, monkeypatch):
(convert_command.base_path / "test").mkdir()
convert_command.input_test_source_dir("app_name", None)

intro_content = "\n\nBased on your project's folder structure, we believe 'tests' might be your test directory"
intro_content = (
"\n\nBased on your project's folder structure, we believe 'tests' might be your"
" test directory"
)
mock_text_question.assert_called_once_with(
intro=PartialMatchString(intro_content),
description="Test Source Directory",
Expand Down
20 changes: 10 additions & 10 deletions tests/commands/convert/test_migrate_necessary_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ def test_warning_without_changelog_file(
)

convert_command.console.warning.assert_called_once_with(
f"\nChangelog file not found in {convert_command.base_path!r}. You should either "
f"create a new changelog file in {convert_command.base_path!r}, or rename an "
"existing file to a known changelog file name (one of 'CHANGELOG', "
"'HISTORY', 'NEWS' or 'RELEASES'; the file may have an extension of "
"'.md', '.rst', '.txt', or have no extension)"
f"\nChangelog file not found in {convert_command.base_path!r}. You should"
f" either create a new changelog file in {convert_command.base_path!r}, or"
" rename an existing file to a known changelog file name (one of 'CHANGELOG',"
" 'HISTORY', 'NEWS' or 'RELEASES'; the file may have an extension of '.md',"
" '.rst', '.txt', or have no extension)"
)


Expand Down Expand Up @@ -247,11 +247,11 @@ def test_two_warnings_without_license_and_changelog_file(
"Briefcase will create a template 'LICENSE' file."
)
changelog_warning = (
f"\nChangelog file not found in {convert_command.base_path!r}. You should either "
f"create a new changelog file in {convert_command.base_path!r}, or rename an "
"existing file to a known changelog file name (one of 'CHANGELOG', "
"'HISTORY', 'NEWS' or 'RELEASES'; the file may have an extension of "
"'.md', '.rst', '.txt', or have no extension)"
f"\nChangelog file not found in {convert_command.base_path!r}. You should"
f" either create a new changelog file in {convert_command.base_path!r}, or"
" rename an existing file to a known changelog file name (one of 'CHANGELOG',"
" 'HISTORY', 'NEWS' or 'RELEASES'; the file may have an extension of '.md',"
" '.rst', '.txt', or have no extension)"
)
assert convert_command.console.warning.mock_calls == [
mock.call(license_warning),
Expand Down
15 changes: 12 additions & 3 deletions tests/commands/create/test_create_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ def test_create_existing_app_overwrite(tracking_create_command, tmp_path):

# Input was required by the user
assert tracking_create_command.console.prompts == [
f"The directory {bundle_path.relative_to(base_path)} already exists; overwrite [y/N]? "
(
f"The directory {bundle_path.relative_to(base_path)} already exists;"
" overwrite [y/N]? "
),
]

# The right sequence of things will be done
Expand Down Expand Up @@ -85,7 +88,10 @@ def test_create_existing_app_no_overwrite(tracking_create_command, tmp_path):

# Input was required by the user
assert tracking_create_command.console.prompts == [
f"The directory {bundle_path.relative_to(base_path)} already exists; overwrite [y/N]? "
(
f"The directory {bundle_path.relative_to(base_path)} already exists;"
" overwrite [y/N]? "
),
]

# No app creation actions will be performed
Expand Down Expand Up @@ -113,7 +119,10 @@ def test_create_existing_app_no_overwrite_default(tracking_create_command, tmp_p

# Input was required by the user
assert tracking_create_command.console.prompts == [
f"The directory {bundle_path.relative_to(base_path)} already exists; overwrite [y/N]? "
(
f"The directory {bundle_path.relative_to(base_path)} already exists;"
" overwrite [y/N]? "
),
]

# And no actions were necessary
Expand Down
7 changes: 5 additions & 2 deletions tests/commands/create/test_generate_app_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def full_context():
"host_arch": "gothic",
"briefcase_version": briefcase.__version__,
# Properties of the template
"template_source": "https://github.com/beeware/briefcase-Tester-Dummy-template.git",
"template_source": (
"https://github.com/beeware/briefcase-Tester-Dummy-template.git"
),
"template_branch": f"v{briefcase.__version__}",
# Fields generated from other properties
"module_name": "my_app",
Expand Down Expand Up @@ -753,5 +755,6 @@ def test_cookiecutter_undefined_variable_in_template(
BriefcaseConfigError,
match=f"Briefcase configuration error: {cookiecutter_exception_message}",
):
# Generating the template with an undefined cookiecutter variable generates an error
# Generating the template with an undefined cookiecutter variable generates
# an error
create_command.generate_app_template(myapp)
3 changes: 2 additions & 1 deletion tests/commands/create/test_install_app_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ def test_source_dir_merge_and_file_overwrite(
"# test_top from testdir\n",
)

# Set the app definition with two sources and two test sources, and two top-level files with the same name
# Set the app definition with two sources and two test sources, and two top-level
# files with the same name
myapp.sources = ["lib", "srcdir/lib", "top.py", "srcdir/top.py"]
myapp.test_sources = [
"tests",
Expand Down
12 changes: 8 additions & 4 deletions tests/commands/create/test_install_app_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def test_bad_path_index(create_command, myapp, bundle_path, app_requirements_pat
# Install requirements
with pytest.raises(
BriefcaseCommandError,
match=r"Application path index file does not define `app_requirements_path` or `app_packages_path`",
match=(
r"Application path index file does not define `app_requirements_path` or"
r" `app_packages_path`"
),
):
create_command.install_app_requirements(myapp)

Expand Down Expand Up @@ -358,7 +361,8 @@ def test_app_packages_valid_requires_no_support_package(
specified."""
myapp.requires = ["first", "second==1.2.3", "third>=3.2.1"]

# Override the cache of paths to specify an app packages path, but no support package path
# Override the cache of paths to specify an app packages path, but no support
# package path
create_command._briefcase_toml[myapp] = {
"paths": {"app_packages_path": "path/to/app_packages"}
}
Expand Down Expand Up @@ -738,7 +742,7 @@ def test_app_requirements_requirement_installer_args_with_template_support(
assert myapp.test_requires is None


def test_app_requirements_requirement_installer_args_without_requires_no_template_support(
def test_app_requirements_requirement_installer_args_without_requires_no_template_support( # noqa: E501
create_command,
myapp,
app_path,
Expand Down Expand Up @@ -768,7 +772,7 @@ def test_app_requirements_requirement_installer_args_without_requires_no_templat
assert myapp.test_requires is None


def test_app_requirements_requirement_installer_args_without_requires_with_template_support(
def test_app_requirements_requirement_installer_args_without_requires_with_template_support( # noqa: E501
create_command,
myapp,
app_path,
Expand Down
Loading