Apply `ruff format .`

pull/11209/head
John-Scott Atlakson 2023-11-16 15:43:25 -08:00 zatwierdzone przez Sage Abdullah
rodzic 9a2177dc19
commit f8fc2c3a20
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: EB1A33CC51CC0217
59 zmienionych plików z 53 dodań i 121 usunięć

Wyświetl plik

@ -58,7 +58,7 @@ language_names = [
]
language_names.sort()
for (language_name, locale) in language_names:
for language_name, locale in language_names:
print(f"{language_name} - {locale}") # noqa: T201
print("-----") # noqa: T201
for author in sorted(authors_by_locale[locale]):

Wyświetl plik

@ -145,7 +145,6 @@ class CopyPageAction:
)
# Save copied child objects and run process_child_object on them if we need to
for (child_relation, old_pk), child_object in child_object_map.items():
if self.process_child_object:
self.process_child_object(
specific_page, page_copy, child_relation, child_object

Wyświetl plik

@ -106,7 +106,6 @@ class CreatePageAliasAction:
reset_translation_key,
_mpnode_attrs,
):
specific_page = page.specific
# FIXME: Switch to the same fields that are excluded from copy

Wyświetl plik

@ -57,7 +57,6 @@ class UnpublishPageAction(UnpublishAction):
super().execute(skip_permission_checks)
if self.include_descendants:
for live_descendant_page in (
self.object.get_descendants()
.live()

Wyświetl plik

@ -127,7 +127,6 @@ def reject_request(request):
def require_admin_access(view_func):
def decorated_view(request, *args, **kwargs):
user = request.user
if user.is_anonymous:

Wyświetl plik

@ -297,7 +297,6 @@ class BaseGroupCollectionMemberPermissionFormSet(forms.BaseFormSet):
def collection_member_permission_formset_factory(
model, permission_types, template, default_prefix=None
):
permission_queryset = Permission.objects.filter(
content_type__app_label=model._meta.app_label,
codename__in=[

Wyświetl plik

@ -33,7 +33,6 @@ class TagField(TaggitTagField):
self.widget.free_tagging = self.free_tagging
def clean(self, value):
value = super().clean(value)
max_tag_length = self.tag_model.name.field.max_length

Wyświetl plik

@ -97,7 +97,6 @@ def send_notification(recipient_users, notification, extra_context):
connection = get_connection()
with OpenedConnection(connection) as open_connection:
# Send emails
sent_count = 0
for recipient in email_recipients:
@ -229,12 +228,10 @@ class EmailNotificationMixin:
}
def send_emails(self, template_set, context, recipients, **kwargs):
connection = get_connection()
sent_count = 0
try:
with OpenedConnection(connection) as open_connection:
# Send emails
for recipient in recipients:
# update context with this recipient

Wyświetl plik

@ -16,9 +16,7 @@ from wagtail.models import Page
# management command.
class Admin(Model):
class Meta:
default_permissions = (
[]
) # don't create the default add / change / delete / view perms
default_permissions = [] # don't create the default add / change / delete / view perms
permissions = [
("access_admin", "Can access Wagtail admin"),
]

Wyświetl plik

@ -110,11 +110,10 @@ class FieldPanel(Panel):
labels = dict(choices)
display_values = [
str(labels.get(v, v)) # Use raw value if no match found
for v in (
for v in
(
# Account for single AND multiple choice fields
tuple(value)
if isinstance(value, (list, tuple))
else (value,)
tuple(value) if isinstance(value, (list, tuple)) else (value,)
)
]
return ", ".join(display_values)
@ -275,7 +274,6 @@ class FieldPanel(Panel):
return context
def get_editable_context_data(self):
widget_described_by_ids = []
help_text_id = "%s-helptext" % self.prefix
error_message_id = "%s-errors" % self.prefix

Wyświetl plik

@ -46,7 +46,6 @@ class TitleFieldPanel(FieldPanel):
}
class BoundPanel(FieldPanel.BoundPanel):
apply_actions = [
"focus->w-sync#check",
"blur->w-sync#apply",

Wyświetl plik

@ -253,9 +253,7 @@ def test_page_is_public(context, page):
"request"
].all_page_view_restriction_paths = PageViewRestriction.objects.select_related(
"page"
).values_list(
"page__path", flat=True
)
).values_list("page__path", flat=True)
is_private = any(
page.path.startswith(restricted_path)

Wyświetl plik

@ -6,7 +6,6 @@ from wagtail.test.utils import WagtailTestUtils
class TestBulkActionDispatcher(WagtailTestUtils, TestCase):
def setUp(self):
# Login
self.user = self.login()

Wyświetl plik

@ -1856,7 +1856,7 @@ class TestPageEdit(WagtailTestUtils, TestCase):
def test_override_default_action_menu_item(self):
def hook_func(menu_items, request, context):
for (index, item) in enumerate(menu_items):
for index, item in enumerate(menu_items):
if item.name == "action-publish":
# move to top of list
menu_items.pop(index)

Wyświetl plik

@ -1751,7 +1751,6 @@ class TestCommentPanel(WagtailTestUtils, TestCase):
self.assertEqual(replies_formset.forms[0].for_user, self.commenting_user)
def test_comment_form_validation(self):
form = self.EventPageForm(
{
"comments-TOTAL_FORMS": 2,
@ -1872,7 +1871,6 @@ class TestCommentPanel(WagtailTestUtils, TestCase):
)
def test_comment_reply_form_validation(self):
form = self.EventPageForm(
{
"comments-TOTAL_FORMS": 1,
@ -2378,7 +2376,6 @@ class TestTitleFieldPanel(WagtailTestUtils, TestCase):
self.assertEqual(attrs["data-w-sync-target-value"], "#id_cost, #id_location")
def test_classname_override(self):
html = self.get_edit_handler_html(
ObjectList(
[TitleFieldPanel("title", classname="super-title"), FieldPanel("slug")]

Wyświetl plik

@ -122,7 +122,6 @@ class TestLockedPagesView(WagtailTestUtils, TestCase):
self.assertRedirects(response, reverse("wagtailadmin_home"))
def test_csv_export(self):
self.page = Page.objects.first()
self.page.locked = True
self.page.locked_by = self.user
@ -156,7 +155,6 @@ class TestLockedPagesView(WagtailTestUtils, TestCase):
)
def test_xlsx_export(self):
self.page = Page.objects.first()
self.page.locked = True
self.page.locked_by = self.user

Wyświetl plik

@ -6,7 +6,6 @@ from wagtail.test.utils import WagtailTestUtils
class TestGenericIndexView(WagtailTestUtils, TestCase):
fixtures = ["test.json"]
def get(self, params={}):
@ -26,7 +25,6 @@ class TestGenericIndexView(WagtailTestUtils, TestCase):
class TestGenericEditView(WagtailTestUtils, TestCase):
fixtures = ["test.json"]
def get(self, object_pk, params={}):
@ -63,7 +61,6 @@ class TestGenericEditView(WagtailTestUtils, TestCase):
class TestGenericDeleteView(WagtailTestUtils, TestCase):
fixtures = ["test.json"]
def get(self, object_pk, params={}):

Wyświetl plik

@ -68,7 +68,6 @@ class TestAdaptLinkMenuItem(TestCase):
)
def test_adapt_with_deprecated_classnames(self):
with self.assertWarnsRegex(
RemovedInWagtail70Warning,
"The `classnames` kwarg for sidebar LinkMenuItem is deprecated - use `classname` instead.",

Wyświetl plik

@ -18,7 +18,6 @@ class AdminItem(BaseItem):
template = "wagtailadmin/userbar/item_admin.html"
def render(self, request):
# Don't render if user doesn't have permission to access the admin area
if not request.user.has_perm("wagtailadmin.access_admin"):
return ""

Wyświetl plik

@ -20,7 +20,6 @@ class PermissionCheckedMixin:
def dispatch(self, request, *args, **kwargs):
if self.permission_policy is not None:
if self.permission_required is not None:
if not self.user_has_permission(self.permission_required):
raise PermissionDenied

Wyświetl plik

@ -285,7 +285,6 @@ class RecentEditsPanel(Component):
class HomeView(WagtailAdminTemplateMixin, TemplateView):
template_name = "wagtailadmin/home.html"
page_title = gettext_lazy("Dashboard")

Wyświetl plik

@ -221,7 +221,7 @@ class UpdateModulePaths(Command):
checked_file_count = 0
changed_file_count = 0
for (dirpath, dirnames, filenames) in os.walk(root_path):
for dirpath, dirnames, filenames in os.walk(root_path):
dirpath_with_slash = os.path.abspath(dirpath) + os.sep
if any(
dirpath_with_slash.startswith(ignored_dir)

Wyświetl plik

@ -491,7 +491,6 @@ class BaseChoiceBlock(FieldBlock):
validators=(),
**kwargs,
):
self._required = required
self._default = default
self.search_index = search_index

Wyświetl plik

@ -155,9 +155,7 @@ class BaseStructBlock(Block):
)
def clean(self, value):
result = (
[]
) # build up a list of (name, value) tuples to be passed to the StructValue constructor
result = [] # build up a list of (name, value) tuples to be passed to the StructValue constructor
errors = {}
for name, val in value.items():
try:
@ -180,7 +178,7 @@ class BaseStructBlock(Block):
child_block.to_python(value[name])
if name in value
else child_block.get_default()
)
),
# NB the result of get_default is NOT passed through to_python, as it's expected
# to be in the block's native type already
)

Wyświetl plik

@ -567,7 +567,6 @@ class TestFormWithRedirect(TestCase):
class TestFormPageWithCustomFormBuilder(WagtailTestUtils, TestCase):
def setUp(self):
home_page = Page.objects.get(url_path="/home/")
form_page = home_page.add_child(
instance=FormPageWithCustomFormBuilder(

Wyświetl plik

@ -1602,7 +1602,6 @@ class TestDuplicateFormFieldLabels(WagtailTestUtils, TestCase):
fixtures = ["test.json"]
def setUp(self):
self.login(username="superuser", password="password")
# Find root page
self.root_page = Page.objects.get(id=2)
@ -1759,7 +1758,6 @@ class TestDuplicateFormFieldLabels(WagtailTestUtils, TestCase):
class TestPreview(WagtailTestUtils, TestCase):
post_data = {
"title": "Form page!",
"content": "Some content",

Wyświetl plik

@ -342,7 +342,6 @@ class AzureBaseBackend(BaseBackend):
class AzureFrontDoorBackend(AzureBaseBackend):
def __init__(self, params):
super().__init__(params)
try:
self._front_door_name = params.pop("FRONT_DOOR_NAME")
@ -372,7 +371,6 @@ class AzureFrontDoorBackend(AzureBaseBackend):
class AzureCdnBackend(AzureBaseBackend):
def __init__(self, params):
super().__init__(params)
try:
self._cdn_profile_name = params.pop("CDN_PROFILE_NAME")

Wyświetl plik

@ -422,7 +422,6 @@ class MockCloudflareBackend(CloudflareBackend):
}
)
class TestCachePurgingFunctions(TestCase):
fixtures = ["test.json"]
def setUp(self):
@ -496,7 +495,6 @@ class TestCloudflareCachePurgingFunctions(TestCase):
}
)
class TestCachePurgingSignals(TestCase):
fixtures = ["test.json"]
def setUp(self):

Wyświetl plik

@ -93,7 +93,6 @@ def _page_urls_for_sites(
) -> Set[Tuple[Site, str, str]]:
urls = set()
for site in sites:
# use a `HttpRequest` to influence the return value
request = get_dummy_request(site=site)
# reuse cached site root paths if available

Wyświetl plik

@ -167,7 +167,6 @@ class TestAutocreateRedirects(WagtailTestUtils, TestCase):
)
def test_no_redirects_created_when_pages_are_moved_to_a_different_site(self):
# Add a new home page
homepage_2 = Page(
title="Second home",

Wyświetl plik

@ -35,7 +35,6 @@ class SettingModelTestCase(SiteSettingsTestMixin, TestCase):
# even when the requests are for the same site
for i, request in enumerate([self.get_request(), self.get_request()], 1):
with self.subTest(attempt=i):
# force site query beforehand
Site.find_for_request(request)
@ -138,7 +137,6 @@ class SettingModelTestCase(SiteSettingsTestMixin, TestCase):
("privacy_policy_page", "http://other/"),
):
with self.subTest(page_fk_field=page_fk_field):
with self.assertNumQueries(1):
# because results are cached, only the first
# request for a URL will trigger a query to
@ -174,7 +172,6 @@ class SettingModelTestCase(SiteSettingsTestMixin, TestCase):
("privacy_policy_page", "http://other/"),
):
with self.subTest(page_fk_field=page_fk_field):
# only the first request for each URL will trigger queries.
# 2 are triggered instead of 1 here, because tests use the
# database cache backed, and the cache is queried each time
@ -182,7 +179,6 @@ class SettingModelTestCase(SiteSettingsTestMixin, TestCase):
# store them on)
with self.assertNumQueries(2):
self.assertEqual(
settings.get_page_url(page_fk_field), expected_result
)

Wyświetl plik

@ -42,7 +42,6 @@ class Sitemap(DjangoSitemap):
last_mods = set()
for item in self.paginator.page(page).object_list.iterator():
url_info_items = item.get_sitemap_urls(self.request)
for url_info in url_info_items:

Wyświetl plik

@ -77,7 +77,6 @@ def serve(request, document_id, document_filename):
return redirect(direct_url)
if local_path:
# Use wagtail.utils.sendfile to serve the file;
# this provides support for mimetypes, if-modified-since and django-sendfile backends
@ -93,7 +92,6 @@ def serve(request, document_id, document_filename):
return sendfile(request, local_path, **sendfile_opts)
else:
# We are using a storage backend which does not expose filesystem paths
# (e.g. storages.backends.s3boto.S3BotoStorage) AND the developer has not allowed
# redirecting to the file url directly.

Wyświetl plik

@ -41,7 +41,7 @@ class RichTextField(models.TextField):
field = super().formfield(**defaults)
# replace any MaxLengthValidators with RichTextMaxLengthValidators to ignore tags
for (i, validator) in enumerate(field.validators):
for i, validator in enumerate(field.validators):
if isinstance(validator, MaxLengthValidator):
field.validators[i] = RichTextMaxLengthValidator(
validator.limit_value, message=validator.message
@ -244,7 +244,6 @@ class StreamField(models.Field):
return self.get_prep_value(value)
def get_searchable_content(self, value):
return self.stream_block.get_searchable_content(value)
def extract_references(self, value):

Wyświetl plik

@ -939,7 +939,6 @@ class Filter:
def run(self, image: AbstractImage, output: BytesIO, source: File = None):
with self.get_willow_image(image, source) as willow:
original_format = willow.format_name
# Fix orientation of image

Wyświetl plik

@ -740,7 +740,6 @@ class TestImageAddView(WagtailTestUtils, TestCase):
self.assertEqual(image.collection, evil_plans_collection)
def test_add_with_selected_collection(self):
root_collection = Collection.get_first_root_node()
collection = root_collection.add_child(name="Travel pics")

Wyświetl plik

@ -10,7 +10,6 @@ from .utils import Image, get_test_image_file
class TestShortcuts(TestCase):
fixtures = ["test.json"]
def test_fallback_to_not_found(self):

Wyświetl plik

@ -116,7 +116,7 @@ class BaseListingView(TemplateView):
if self.current_tag:
try:
images = images.filter(tags__name=self.current_tag)
except (AttributeError):
except AttributeError:
self.current_tag = None
entries_per_page = self.get_num_entries_per_page()

Wyświetl plik

@ -7,7 +7,6 @@ class Command(BaseCommand):
help = "Deletes all of the Embed model objects"
def handle(self, *args, **options):
embeds = Embed.objects.all()
deleted_embeds_count = embeds.delete()[0]

Wyświetl plik

@ -4,7 +4,6 @@ from wagtail.models import Page
class Command(BaseCommand):
help = "Resets url_path fields on each page recursively"
def set_subtree(self, root, parent=None):

Wyświetl plik

@ -69,9 +69,7 @@ class LogEntryQuerySet(models.QuerySet):
for log_entry in log_entries:
ids_by_content_type[log_entry.content_type_id].append(log_entry.object_id)
instances_by_id = (
{}
) # lookup of (content_type_id, stringified_object_id) to instance
instances_by_id = {} # lookup of (content_type_id, stringified_object_id) to instance
for content_type_id, object_ids in ids_by_content_type.items():
try:
content_type = ContentType.objects.get_for_id(content_type_id)

Wyświetl plik

@ -336,9 +336,12 @@ class ReferenceIndex(models.Model):
# select the appropriate superclass if necessary, before converting back to a
# content type.
model = ContentType.objects.get_for_id(ct_value).model_class()
yield cls._get_base_content_type(model).id, str(
fk_value
), field.name, field.name
yield (
cls._get_base_content_type(model).id,
str(fk_value),
field.name,
field.name,
)
continue
@ -347,9 +350,12 @@ class ReferenceIndex(models.Model):
value = field.value_from_object(object)
if value is not None:
yield cls._get_base_content_type(field.related_model).id, str(
value
), field.name, field.name
yield (
cls._get_base_content_type(field.related_model).id,
str(value),
field.name,
field.name,
)
if hasattr(field, "extract_references"):
value = field.value_from_object(object)
@ -483,7 +489,7 @@ class ReferenceIndex(models.Model):
deleted_reference_ids = []
# Look at the reference record and the supporting content_type / id for each existing
# reference in the database
for (reference_data, (content_type_id, id)) in existing_references.items():
for reference_data, (content_type_id, id) in existing_references.items():
if reference_data in references:
# Do not delete this reference, as it is still present in the new set
continue

Wyświetl plik

@ -520,7 +520,6 @@ class SpecificIterable(BaseIterable):
# Gather items in batches to reduce peak memory usage
for values in self._get_chunks(values_qs):
annotations_by_pk = defaultdict(list)
if annotation_aliases:
# Extract annotation results keyed by pk so we can reapply to fetched items.

Wyświetl plik

@ -491,9 +491,7 @@ class MySQLSearchQueryCompiler(BaseSearchQueryCompiler):
)
if not negated:
index_entries = index_entries.filter(match_expression)
if (
self.order_by_relevance
): # Only applies to the case where the outermost query is not a Not(), because if it is, the relevance score is always 0 (anything that matches is excluded from the results).
if self.order_by_relevance: # Only applies to the case where the outermost query is not a Not(), because if it is, the relevance score is always 0 (anything that matches is excluded from the results).
index_entries = index_entries.order_by(score_expression.desc())
else:
index_entries = index_entries.exclude(match_expression)

Wyświetl plik

@ -15,8 +15,7 @@ class LexemeCombinable(Expression):
def _combine(self, other, connector, reversed, node=None):
if not isinstance(other, LexemeCombinable):
raise TypeError(
"Lexeme can only be combined with other Lexemes, "
"got {}.".format(type(other))
f"Lexeme can only be combined with other Lexemes, got {type(other)}."
)
if reversed:
return CombinedLexeme(other, connector, self)
@ -235,10 +234,13 @@ class MatchExpression(Expression):
) -> None:
super().__init__(output_field=output_field)
self.query = query
self.columns = columns or [
"title",
"body",
] # We need to provide a default list of columns if the user doesn't specify one. We have a joint index for for 'title' and 'body' (see wagtail.search.migrations.0006_customise_indexentry), so we'll pick that one.
self.columns = (
columns
or [
"title",
"body",
]
) # We need to provide a default list of columns if the user doesn't specify one. We have a joint index for for 'title' and 'body' (see wagtail.search.migrations.0006_customise_indexentry), so we'll pick that one.
def as_sql(self, compiler, connection):
compiled_query = compiler.compile(self.query) # Compile the query to a string

Wyświetl plik

@ -9,8 +9,7 @@ class LexemeCombinable(Expression):
def _combine(self, other, connector, reversed, node=None):
if not isinstance(other, LexemeCombinable):
raise TypeError(
"Lexeme can only be combined with other Lexemes, "
"got {}.".format(type(other))
f"Lexeme can only be combined with other Lexemes, got {type(other)}."
)
if reversed:
return CombinedLexeme(other, connector, self)

Wyświetl plik

@ -34,8 +34,7 @@ class LexemeCombinable(Expression):
def _combine(self, other, connector, reversed, node=None):
if not isinstance(other, LexemeCombinable):
raise TypeError(
"Lexeme can only be combined with other Lexemes, "
"got {}.".format(type(other))
f"Lexeme can only be combined with other Lexemes, got {type(other)}."
)
if reversed:
return CombinedLexeme(other, connector, self)
@ -248,9 +247,7 @@ def normalize(search_query: SearchQuery) -> Tuple[SearchQuery]:
): # If there are no negated subqueries, return an And(), now without the redundant MatchAll subqueries.
return And(not_negated_subqueries)
for (
subquery
) in (
for subquery in (
negated_subqueries
): # If there's a negated MatchAll subquery, then nothing will get matched.
if isinstance(subquery, MatchAll):
@ -272,9 +269,7 @@ def normalize(search_query: SearchQuery) -> Tuple[SearchQuery]:
): # If there are no negated subqueries, return an Or().
return Or(normalized_subqueries)
for (
subquery
) in (
for subquery in (
negated_subqueries
): # If there's a MatchAll subquery, then anything will get matched.
if isinstance(subquery, MatchAll):

Wyświetl plik

@ -471,7 +471,6 @@ class SQLiteSearchQueryCompiler(BaseSearchQueryCompiler):
return self.get_index_vectors()
def _build_rank_expression(self, vectors, config):
# TODO: Come up with my own expression class that compiles down to bm25
rank_expressions = [
@ -508,7 +507,9 @@ class SQLiteSearchQueryCompiler(BaseSearchQueryCompiler):
vectors = self.get_search_vectors()
rank_expression = self._build_rank_expression(vectors, config)
combined_vector = vectors[0][
combined_vector = vectors[
0
][
0
] # We create a combined vector for the search results queryset. We start with the first vector and build from there.
for vector, boost in vectors[1:]:

Wyświetl plik

@ -303,6 +303,6 @@ class TestBalancedReduce(SimpleTestCase):
repr(
balanced_reduce(CombinedNode, ["A", "B", "C", "D", "E", "F", "G", "H"])
),
"(((A B) (C D)) ((E F) (G H)))"
"(((A B) (C D)) ((E F) (G H)))",
# Note: functools.reduce will return '(((((((A B) C) D) E) F) G) H)'
)

Wyświetl plik

@ -4980,7 +4980,6 @@ class TestSnippetChosen(WagtailTestUtils, TestCase):
self.assertEqual(response_json["step"], "chosen")
def test_choose_a_non_existing_page(self):
response = self.get(999999)
self.assertEqual(response.status_code, 404)
@ -5695,7 +5694,6 @@ class TestPanelConfigurationChecks(WagtailTestUtils, TestCase):
self.get_checks_result = get_checks_result
def test_model_with_single_tabbed_panel_only(self):
StandardSnippet.content_panels = [FieldPanel("text")]
warning = checks.Warning(

Wyświetl plik

@ -685,7 +685,6 @@ class FormField(AbstractFormField):
class FormPage(AbstractForm):
page_ptr = models.OneToOneField(
Page, parent_link=True, related_name="+", on_delete=models.CASCADE
)

Wyświetl plik

@ -58,7 +58,6 @@ class CustomSubmissionsListView(SubmissionsListView):
class TestIndexView(IndexView):
model = ModelWithStringTypePrimaryKey
index_url_name = "testapp_generic_index"
template_name = "tests/generic_view_templates/index.html"
@ -73,7 +72,6 @@ class CustomModelEditForm(forms.ModelForm):
class TestEditView(EditView):
model = ModelWithStringTypePrimaryKey
context_object_name = "test_object"
template_name = "tests/generic_view_templates/edit.html"
@ -87,7 +85,6 @@ class TestEditView(EditView):
class TestDeleteView(DeleteView):
model = ModelWithStringTypePrimaryKey
context_object_name = "test_object"
template_name = "tests/generic_view_templates/delete.html"

Wyświetl plik

@ -21,7 +21,6 @@ logger = logging.getLogger(__file__)
class ParentNodeFactory(ParameteredAttribute):
EXTEND_CONTAINERS = True
FORCE_SEQUENCE = False
UNROLL_CONTEXT_BEFORE_EVALUATION = False
@ -43,7 +42,6 @@ class ParentNodeFactory(ParameteredAttribute):
class MP_NodeFactory(DjangoModelFactory):
parent = ParentNodeFactory()
@classmethod

Wyświetl plik

@ -152,7 +152,6 @@ class TestExceptionRaisedForInstance(BadDataMigrationTestCase):
self.append_invalid_instance_data()
def test_migrate(self):
with self.assertRaisesMessage(
InvalidBlockDefError,
"Invalid block def in {} object ({})".format(

Wyświetl plik

@ -1385,7 +1385,6 @@ class TestCopyPage(TestCase):
)
def test_copy_page_with_process_child_object_supplied(self):
# We'll provide this when copying and test that it gets called twice:
# Once for the single speaker, and another for the single advert_placement
modify_child = Mock()

Wyświetl plik

@ -892,7 +892,6 @@ class TestSpecificQuery(WagtailTestUtils, TestCase):
)
def test_specific_query_with_annotations_performs_no_additional_queries(self):
with self.assertNumQueries(5):
pages = list(self.live_pages)

Wyświetl plik

@ -30,7 +30,7 @@ class PermissionPolicyTestUtils:
user = test_case[0]
expected_results = zip(actions, test_case[1:])
for (action, expected_result) in expected_results:
for action, expected_result in expected_results:
if expected_result:
self.assertTrue(
self.policy.user_has_permission(user, action),
@ -58,7 +58,7 @@ class PermissionPolicyTestUtils:
user = test_case[0]
expected_results = zip(actions, test_case[1:])
for (action, expected_result) in expected_results:
for action, expected_result in expected_results:
if expected_result:
self.assertTrue(
self.policy.user_has_permission_for_instance(

Wyświetl plik

@ -38,7 +38,7 @@ class TestCamelCaseToUnderscore(TestCase):
("longValueWithVarious subStrings", "long_value_with_various sub_strings"),
]
for (original, expected_result) in test_cases:
for original, expected_result in test_cases:
self.assertEqual(camelcase_to_underscore(original), expected_result)
@ -59,7 +59,7 @@ class TestStringToAscii(TestCase):
("〔山脈〕", "[ShanMai]"),
]
for (original, expected_result) in test_cases:
for original, expected_result in test_cases:
self.assertEqual(string_to_ascii(original), expected_result)
@ -78,7 +78,7 @@ class TestCautiousSlugify(TestCase):
("Hello☃world", "helloworld"),
]
for (original, expected_result) in test_cases:
for original, expected_result in test_cases:
self.assertEqual(slugify(original), expected_result)
self.assertEqual(cautious_slugify(original), expected_result)
@ -89,7 +89,7 @@ class TestCautiousSlugify(TestCase):
("〔山脈〕", "u5c71u8108"),
]
for (original, expected_result) in test_cases:
for original, expected_result in test_cases:
self.assertEqual(cautious_slugify(original), expected_result)
@ -118,7 +118,7 @@ class TestSafeSnakeCase(TestCase):
),
]
for (original, expected_result) in test_cases:
for original, expected_result in test_cases:
self.assertEqual(safe_snake_case(original), expected_result)
def test_strings_with__non_latin_chars(self):
@ -127,7 +127,7 @@ class TestSafeSnakeCase(TestCase):
("Сп орт!", "u0421u043f_u043eu0440u0442"),
]
for (original, expected_result) in test_cases:
for original, expected_result in test_cases:
self.assertEqual(safe_snake_case(original), expected_result)

Wyświetl plik

@ -33,7 +33,7 @@ class assets_mixin:
try:
package = json.loads(input_file.read().decode("utf-8"))
except (ValueError) as e:
except ValueError as e:
print("Unable to read " + path + " " + e) # noqa: T201
raise SystemExit(1)
@ -42,7 +42,7 @@ class assets_mixin:
try:
with open(path, "w", encoding="utf-8") as f:
f.write(str(json.dumps(package, indent=2, ensure_ascii=False)))
except (OSError) as e:
except OSError as e:
print( # noqa: T201
"Error setting the version for front-end assets: " + str(e)
)
@ -71,7 +71,6 @@ class sdist(base_sdist, assets_mixin):
class check_bdist_egg(bdist_egg):
# If this file does not exist, warn the user to compile the assets
sentinel_dir = "wagtail/wagtailadmin/static/"