Fix flake8 A504 errors

pull/10060/head
Sage Abdullah 2023-01-25 15:58:29 +00:00 zatwierdzone przez Matt Westcott
rodzic 32bc42b64a
commit d73210026d
6 zmienionych plików z 24 dodań i 23 usunięć

Wyświetl plik

@ -153,7 +153,7 @@ class TestBulkDelete(WagtailTestUtils, TestCase):
# treebeard should report no consistency problems with the tree
self.assertFalse(
any(Page.find_problems()), "treebeard found consistency problems"
any(Page.find_problems()), msg="treebeard found consistency problems"
)
# Check that the child pages to be deleted are gone
@ -206,7 +206,7 @@ class TestBulkDelete(WagtailTestUtils, TestCase):
# treebeard should report no consistency problems with the tree
self.assertFalse(
any(Page.find_problems()), "treebeard found consistency problems"
any(Page.find_problems()), msg="treebeard found consistency problems"
)
# Check that the child pages to be deleted are gone
@ -268,7 +268,7 @@ class TestBulkDelete(WagtailTestUtils, TestCase):
# treebeard should report no consistency problems with the tree
self.assertFalse(
any(Page.find_problems()), "treebeard found consistency problems"
any(Page.find_problems()), msg="treebeard found consistency problems"
)
# Check that the child pages to be deleted are gone

Wyświetl plik

@ -449,7 +449,7 @@ class TestPageCreation(WagtailTestUtils, TestCase):
# treebeard should report no consistency problems with the tree
self.assertFalse(
any(Page.find_problems()), "treebeard found consistency problems"
any(Page.find_problems()), msg="treebeard found consistency problems"
)
def test_create_simplepage_scheduled(self):
@ -480,7 +480,7 @@ class TestPageCreation(WagtailTestUtils, TestCase):
self.assertEqual(page.go_live_at.date(), go_live_at.date())
self.assertEqual(page.expire_at.date(), expire_at.date())
self.assertIs(page.expired, False)
self.assertTrue(page.status_string, "draft")
self.assertEqual(page.status_string, "draft")
# No revisions with approved_go_live_at
self.assertFalse(
@ -601,7 +601,7 @@ class TestPageCreation(WagtailTestUtils, TestCase):
# treebeard should report no consistency problems with the tree
self.assertFalse(
any(Page.find_problems()), "treebeard found consistency problems"
any(Page.find_problems()), msg="treebeard found consistency problems"
)
def test_create_simplepage_post_publish_scheduled(self):
@ -643,7 +643,7 @@ class TestPageCreation(WagtailTestUtils, TestCase):
# But Page won't be live
self.assertFalse(page.live)
self.assertFalse(page.first_published_at)
self.assertTrue(page.status_string, "scheduled")
self.assertEqual(page.status_string, "scheduled")
def test_create_simplepage_post_submit(self):
# Create a moderator user for testing email

Wyświetl plik

@ -58,11 +58,11 @@ class TestApproveRejectModeration(WagtailTestUtils, TestCase):
page = Page.objects.get(id=self.page.id)
# Page must be live
self.assertTrue(page.live, "Approving moderation failed to set live=True")
self.assertTrue(page.live, msg="Approving moderation failed to set live=True")
# Page should now have no unpublished changes
self.assertFalse(
page.has_unpublished_changes,
"Approving moderation failed to set has_unpublished_changes=False",
msg="Approving moderation failed to set has_unpublished_changes=False",
)
# Check that the page_published signal was fired
@ -86,13 +86,13 @@ class TestApproveRejectModeration(WagtailTestUtils, TestCase):
page = Page.objects.get(id=self.page.id)
# Page must be live
self.assertTrue(page.live, "Approving moderation failed to set live=True")
self.assertTrue(page.live, msg="Approving moderation failed to set live=True")
# Page content should be the submitted version, not the published one
self.assertEqual(page.title, "Hello world!")
# Page should still have unpublished changes
self.assertTrue(
page.has_unpublished_changes,
"has_unpublished_changes incorrectly cleared on approve_moderation when a later revision exists",
msg="has_unpublished_changes incorrectly cleared on approve_moderation when a later revision exists",
)
def test_approve_moderation_view_bad_revision_id(self):
@ -415,11 +415,11 @@ class TestApproveRejectModerationWithoutUser(WagtailTestUtils, TestCase):
page = Page.objects.get(id=self.page.id)
# Page must be live
self.assertTrue(page.live, "Approving moderation failed to set live=True")
self.assertTrue(page.live, msg="Approving moderation failed to set live=True")
# Page should now have no unpublished changes
self.assertFalse(
page.has_unpublished_changes,
"Approving moderation failed to set has_unpublished_changes=False",
msg="Approving moderation failed to set has_unpublished_changes=False",
)
# Check that the page_published signal was fired

Wyświetl plik

@ -187,8 +187,8 @@ class TestPageListing(WagtailTestUtils, TestCase):
# Only generic fields available
self.assertEqual(set(page.keys()), {"id", "meta", "title"})
self.assertTrue(blog_page_seen, "No blog pages were found in the items")
self.assertTrue(event_page_seen, "No event pages were found in the items")
self.assertTrue(blog_page_seen, msg="No blog pages were found in the items")
self.assertTrue(event_page_seen, msg="No event pages were found in the items")
def test_non_existant_type_gives_error(self):
response = self.get_response(type="demosite.IDontExist")

Wyświetl plik

@ -270,7 +270,7 @@ class TestLocaleDeleteView(WagtailTestUtils, TestCase):
for lang in ("fr", "de", "pl", "ja"):
Locale.objects.create(language_code=lang)
self.assertTrue(Page.get_first_root_node().locale.language_code, "en")
self.assertEqual(Page.get_first_root_node().locale.language_code, "en")
Page.objects.filter(depth__gt=1).delete()
response = self.post()
@ -282,7 +282,7 @@ class TestLocaleDeleteView(WagtailTestUtils, TestCase):
# root node's locale should now have been reassigned to the one matching the current
# LANGUAGE_CODE
self.assertTrue(Page.get_first_root_node().locale.language_code, "de")
self.assertEqual(Page.get_first_root_node().locale.language_code, "de")
@override_settings(
LANGUAGE_CODE="de-at",
@ -297,7 +297,7 @@ class TestLocaleDeleteView(WagtailTestUtils, TestCase):
def test_can_delete_default_locale_when_language_code_has_no_locale(self):
Locale.objects.create(language_code="fr")
self.assertTrue(Page.get_first_root_node().locale.language_code, "en")
self.assertEqual(Page.get_first_root_node().locale.language_code, "en")
Page.objects.filter(depth__gt=1).delete()
response = self.post()
@ -309,7 +309,7 @@ class TestLocaleDeleteView(WagtailTestUtils, TestCase):
# root node's locale should now have been reassigned to 'fr' despite that not matching
# LANGUAGE_CODE (because it's the only remaining Locale record)
self.assertTrue(Page.get_first_root_node().locale.language_code, "fr")
self.assertEqual(Page.get_first_root_node().locale.language_code, "fr")
def test_cannot_delete_last_remaining_locale(self):
Page.objects.filter(depth__gt=1).delete()

Wyświetl plik

@ -33,12 +33,13 @@ class PermissionPolicyTestUtils:
if expected_result:
self.assertTrue(
self.policy.user_has_permission(user, action),
"User %s should be able to %s, but can't" % (user, action),
msg="User %s should be able to %s, but can't" % (user, action),
)
else:
self.assertFalse(
self.policy.user_has_permission(user, action),
"User %s should not be able to %s, but can" % (user, action),
msg="User %s should not be able to %s, but can"
% (user, action),
)
def assertUserInstancePermissionMatrix(self, instance, test_cases):
@ -59,7 +60,7 @@ class PermissionPolicyTestUtils:
self.policy.user_has_permission_for_instance(
user, action, instance
),
"User %s should be able to %s instance %s, but can't"
msg="User %s should be able to %s instance %s, but can't"
% (user, action, instance),
)
else:
@ -67,7 +68,7 @@ class PermissionPolicyTestUtils:
self.policy.user_has_permission_for_instance(
user, action, instance
),
"User %s should not be able to %s instance %s, but can"
msg="User %s should not be able to %s instance %s, but can"
% (user, action, instance),
)