From d007fcf7291cc3c24d4545e23c759bde22b6a8a6 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 6 Feb 2026 11:06:17 -0500 Subject: Modified tests to format PKs with %s rather than %d. It's how Django formats values internally and makes tests compatible with databases that use non-integer primary keys. --- tests/admin_changelist/tests.py | 2 +- tests/admin_filters/tests.py | 8 ++--- tests/admin_inlines/tests.py | 12 +++---- tests/admin_utils/test_logentry.py | 2 +- tests/admin_views/admin.py | 2 +- tests/admin_views/models.py | 2 +- tests/admin_views/tests.py | 20 +++++------ tests/auth_tests/test_context_processors.py | 2 +- tests/auth_tests/test_management.py | 6 ++-- tests/file_uploads/views.py | 2 +- tests/forms_tests/models.py | 2 +- tests/generic_views/test_dates.py | 8 ++--- tests/generic_views/test_edit.py | 56 ++++++++++++++--------------- tests/many_to_one/tests.py | 2 +- tests/model_forms/test_modelchoicefield.py | 12 +++---- tests/model_forms/tests.py | 6 ++-- tests/model_formsets/tests.py | 38 ++++++++++---------- tests/modeladmin/tests.py | 6 ++-- tests/serializers/test_data.py | 4 +-- tests/serializers/test_natural.py | 2 +- 20 files changed, 97 insertions(+), 97 deletions(-) diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py index 330859bcf4..626558f496 100644 --- a/tests/admin_changelist/tests.py +++ b/tests/admin_changelist/tests.py @@ -418,7 +418,7 @@ class ChangeListTests(TestCase): # make sure that hidden fields are in the correct place hiddenfields_div = ( '
' - '' + '' "
" ) % new_child.id self.assertInHTML( diff --git a/tests/admin_filters/tests.py b/tests/admin_filters/tests.py index 530d4c53b6..cef03eb452 100644 --- a/tests/admin_filters/tests.py +++ b/tests/admin_filters/tests.py @@ -700,7 +700,7 @@ class ListFiltersTests(TestCase): choice = select_by(filterspec.choices(changelist), "display", "alfred") self.assertIs(choice["selected"], True) self.assertEqual( - choice["query_string"], "?author__id__exact=%d" % self.alfred.pk + choice["query_string"], "?author__id__exact=%s" % self.alfred.pk ) def test_relatedfieldlistfilter_foreignkey_ordering(self): @@ -803,7 +803,7 @@ class ListFiltersTests(TestCase): choice = select_by(filterspec.choices(changelist), "display", "bob") self.assertIs(choice["selected"], True) self.assertEqual( - choice["query_string"], "?contributors__id__exact=%d" % self.bob.pk + choice["query_string"], "?contributors__id__exact=%s" % self.bob.pk ) def test_relatedfieldlistfilter_reverse_relationships(self): @@ -839,7 +839,7 @@ class ListFiltersTests(TestCase): ) self.assertIs(choice["selected"], True) self.assertEqual( - choice["query_string"], "?books_authored__id__exact=%d" % self.bio_book.pk + choice["query_string"], "?books_authored__id__exact=%s" % self.bio_book.pk ) # M2M relationship ----- @@ -873,7 +873,7 @@ class ListFiltersTests(TestCase): self.assertIs(choice["selected"], True) self.assertEqual( choice["query_string"], - "?books_contributed__id__exact=%d" % self.django_book.pk, + "?books_contributed__id__exact=%s" % self.django_book.pk, ) # With one book, the list filter should appear because there is also a diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py index 4dbaaf8e22..6956c37740 100644 --- a/tests/admin_inlines/tests.py +++ b/tests/admin_inlines/tests.py @@ -1198,7 +1198,7 @@ class TestInlinePermissions(TestCase): ) self.assertContains( response, - '' % self.author_book_auto_m2m_intermediate_id, html=True, ) @@ -1226,7 +1226,7 @@ class TestInlinePermissions(TestCase): ) self.assertNotContains( response, - '' % self.inner2.id, html=True, ) @@ -1258,7 +1258,7 @@ class TestInlinePermissions(TestCase): ) self.assertContains( response, - '' % self.inner2.id, html=True, ) @@ -1305,7 +1305,7 @@ class TestInlinePermissions(TestCase): ) self.assertContains( response, - '' % self.inner2.id, html=True, ) @@ -1335,7 +1335,7 @@ class TestInlinePermissions(TestCase): ) self.assertContains( response, - '' % self.inner2.id, html=True, ) @@ -1375,7 +1375,7 @@ class TestInlinePermissions(TestCase): ) self.assertContains( response, - '' % self.inner2.id, html=True, ) diff --git a/tests/admin_utils/test_logentry.py b/tests/admin_utils/test_logentry.py index 37d13d24bd..43cc281335 100644 --- a/tests/admin_utils/test_logentry.py +++ b/tests/admin_utils/test_logentry.py @@ -224,7 +224,7 @@ class LogEntryTests(TestCase): "admin:admin_utils_article_change", args=(quote(self.a1.pk),) ) self.assertEqual(logentry.get_admin_url(), expected_url) - self.assertIn("article/%d/change/" % self.a1.pk, logentry.get_admin_url()) + self.assertIn("article/%s/change/" % self.a1.pk, logentry.get_admin_url()) logentry.content_type.model = "nonexistent" self.assertIsNone(logentry.get_admin_url()) diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py index 506f9d475d..8e8f7a32cc 100644 --- a/tests/admin_views/admin.py +++ b/tests/admin_views/admin.py @@ -617,7 +617,7 @@ class PostAdmin(admin.ModelAdmin): @admin.display def coolness(self, instance): if instance.pk: - return "%d amount of cool." % instance.pk + return "%s amount of cool." % instance.pk else: return "Unknown coolness." diff --git a/tests/admin_views/models.py b/tests/admin_views/models.py index 2f4e43394a..5191d1605e 100644 --- a/tests/admin_views/models.py +++ b/tests/admin_views/models.py @@ -961,7 +961,7 @@ class _Manager(models.Manager): class FilteredManager(models.Model): def __str__(self): - return "PK=%d" % self.pk + return "PK=%s" % self.pk pk_gt_1 = _Manager() objects = models.Manager() diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 7949622f0e..4beca793d6 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -1300,7 +1300,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): response = self.client.get(reverse("admin:admin_views_workhour_changelist")) self.assertContains(response, "employee__person_ptr__exact") response = self.client.get( - "%s?employee__person_ptr__exact=%d" + "%s?employee__person_ptr__exact=%s" % (reverse("admin:admin_views_workhour_changelist"), e1.pk) ) self.assertEqual(response.status_code, 200) @@ -4769,13 +4769,13 @@ class AdminViewListEditable(TestCase): self.assertContains( response, '
\n' - '' - '\n' + '' + '\n' "
" % (story2.id, story1.id), html=True, ) - self.assertContains(response, '%d' % story1.id, 1) - self.assertContains(response, '%d' % story2.id, 1) + self.assertContains(response, '%s' % story1.id, 1) + self.assertContains(response, '%s' % story2.id, 1) def test_pk_hidden_fields_with_list_display_links(self): """Similarly as test_pk_hidden_fields, but when the hidden pk fields @@ -4798,19 +4798,19 @@ class AdminViewListEditable(TestCase): self.assertContains( response, '
\n' - '' - '\n' + '' + '\n' "
" % (story2.id, story1.id), html=True, ) self.assertContains( response, - '%d' % (link1, story1.id), + '%s' % (link1, story1.id), 1, ) self.assertContains( response, - '%d' % (link2, story2.id), + '%s' % (link2, story2.id), 1, ) @@ -7321,7 +7321,7 @@ class ReadonlyTest(AdminFieldExtractionMixin, TestCase): response = self.client.get( reverse("admin:admin_views_post_change", args=(p.pk,)) ) - self.assertContains(response, "%d amount of cool" % p.pk) + self.assertContains(response, "%s amount of cool" % p.pk) def test_readonly_text_field(self): p = Post.objects.create( diff --git a/tests/auth_tests/test_context_processors.py b/tests/auth_tests/test_context_processors.py index cebc1108dc..85b9e6367b 100644 --- a/tests/auth_tests/test_context_processors.py +++ b/tests/auth_tests/test_context_processors.py @@ -140,7 +140,7 @@ class AuthContextProcessorTests(TestCase): user = authenticate(username="super", password="secret") response = self.client.get("/auth_processor_user/") self.assertContains(response, "unicode: super") - self.assertContains(response, "id: %d" % self.superuser.pk) + self.assertContains(response, "id: %s" % self.superuser.pk) self.assertContains(response, "username: super") # bug #12037 is tested by the {% url %} in the template: self.assertContains(response, "url: /userpage/super/") diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py index 0701ac2d68..f5027da4e5 100644 --- a/tests/auth_tests/test_management.py +++ b/tests/auth_tests/test_management.py @@ -607,7 +607,7 @@ class CreatesuperuserManagementCommandTestCase(TestCase): email = Email.objects.create(email="mymail@gmail.com") Group.objects.all().delete() nonexistent_group_id = 1 - msg = f"group instance with id {nonexistent_group_id} is not a valid choice." + msg = f"group instance with id {nonexistent_group_id!r} is not a valid choice." with self.assertRaisesMessage(CommandError, msg): call_command( @@ -624,7 +624,7 @@ class CreatesuperuserManagementCommandTestCase(TestCase): email = Email.objects.create(email="mymail@gmail.com") Group.objects.all().delete() nonexistent_group_id = 1 - msg = f"group instance with id {nonexistent_group_id} is not a valid choice." + msg = f"group instance with id {nonexistent_group_id!r} is not a valid choice." with mock.patch.dict( os.environ, @@ -644,7 +644,7 @@ class CreatesuperuserManagementCommandTestCase(TestCase): email = Email.objects.create(email="mymail@gmail.com") Group.objects.all().delete() nonexistent_group_id = 1 - msg = f"group instance with id {nonexistent_group_id} is not a valid choice." + msg = f"group instance with id {nonexistent_group_id!r} is not a valid choice." @mock_inputs( { diff --git a/tests/file_uploads/views.py b/tests/file_uploads/views.py index f4f3b5c514..49916845d0 100644 --- a/tests/file_uploads/views.py +++ b/tests/file_uploads/views.py @@ -157,7 +157,7 @@ def file_upload_filename_case_view(request): file = request.FILES["file_field"] obj = FileModel() obj.testfile.save(file.name, file) - return HttpResponse("%d" % obj.pk) + return HttpResponse("%s" % obj.pk) def file_upload_content_type_extra(request): diff --git a/tests/forms_tests/models.py b/tests/forms_tests/models.py index d6d0725b32..b1319abe17 100644 --- a/tests/forms_tests/models.py +++ b/tests/forms_tests/models.py @@ -68,7 +68,7 @@ class ChoiceOptionModel(models.Model): ordering = ("name",) def __str__(self): - return "ChoiceOption %d" % self.pk + return "ChoiceOption %s" % self.pk def choice_default(): diff --git a/tests/generic_views/test_dates.py b/tests/generic_views/test_dates.py index 140083d315..d12b1f6baa 100644 --- a/tests/generic_views/test_dates.py +++ b/tests/generic_views/test_dates.py @@ -895,7 +895,7 @@ class DateDetailViewTests(TestDataMixin, TestCase): def test_datetime_date_detail(self): bs = BookSigning.objects.create(event_date=datetime.datetime(2008, 4, 2, 12, 0)) - res = self.client.get("/dates/booksignings/2008/apr/2/%d/" % bs.pk) + res = self.client.get("/dates/booksignings/2008/apr/2/%s/" % bs.pk) self.assertEqual(res.status_code, 200) @requires_tz_support @@ -904,17 +904,17 @@ class DateDetailViewTests(TestDataMixin, TestCase): bs = BookSigning.objects.create( event_date=datetime.datetime(2008, 4, 2, 12, 0, tzinfo=datetime.UTC) ) - res = self.client.get("/dates/booksignings/2008/apr/2/%d/" % bs.pk) + res = self.client.get("/dates/booksignings/2008/apr/2/%s/" % bs.pk) self.assertEqual(res.status_code, 200) # 2008-04-02T00:00:00+03:00 (beginning of day) > # 2008-04-01T22:00:00+00:00 (book signing event date). bs.event_date = datetime.datetime(2008, 4, 1, 22, 0, tzinfo=datetime.UTC) bs.save() - res = self.client.get("/dates/booksignings/2008/apr/2/%d/" % bs.pk) + res = self.client.get("/dates/booksignings/2008/apr/2/%s/" % bs.pk) self.assertEqual(res.status_code, 200) # 2008-04-03T00:00:00+03:00 (end of day) > 2008-04-02T22:00:00+00:00 # (book signing event date). bs.event_date = datetime.datetime(2008, 4, 2, 22, 0, tzinfo=datetime.UTC) bs.save() - res = self.client.get("/dates/booksignings/2008/apr/2/%d/" % bs.pk) + res = self.client.get("/dates/booksignings/2008/apr/2/%s/" % bs.pk) self.assertEqual(res.status_code, 404) diff --git a/tests/generic_views/test_edit.py b/tests/generic_views/test_edit.py index d66b316090..b483ea1028 100644 --- a/tests/generic_views/test_edit.py +++ b/tests/generic_views/test_edit.py @@ -124,7 +124,7 @@ class CreateViewTests(TestCase): res = self.client.post("/edit/artists/create/", {"name": "Rene Magritte"}) self.assertEqual(res.status_code, 302) artist = Artist.objects.get(name="Rene Magritte") - self.assertRedirects(res, "/detail/artist/%d/" % artist.pk) + self.assertRedirects(res, "/detail/artist/%s/" % artist.pk) self.assertQuerySetEqual(Artist.objects.all(), [artist]) def test_create_with_redirect(self): @@ -148,7 +148,7 @@ class CreateViewTests(TestCase): ) self.assertEqual(res.status_code, 302) pk = Author.objects.first().pk - self.assertRedirects(res, "/edit/author/%d/update/" % pk) + self.assertRedirects(res, "/edit/author/%s/update/" % pk) # Also test with escaped chars in URL res = self.client.post( "/edit/authors/create/interpolate_redirect_nonascii/", @@ -245,7 +245,7 @@ class UpdateViewTests(TestCase): ) def test_update_post(self): - res = self.client.get("/edit/author/%d/update/" % self.author.pk) + res = self.client.get("/edit/author/%s/update/" % self.author.pk) self.assertEqual(res.status_code, 200) self.assertIsInstance(res.context["form"], forms.ModelForm) self.assertEqual(res.context["object"], self.author) @@ -255,7 +255,7 @@ class UpdateViewTests(TestCase): # Modification with both POST and PUT (browser compatible) res = self.client.post( - "/edit/author/%d/update/" % self.author.pk, + "/edit/author/%s/update/" % self.author.pk, {"name": "Randall Munroe (xkcd)", "slug": "randall-munroe"}, ) self.assertEqual(res.status_code, 302) @@ -266,7 +266,7 @@ class UpdateViewTests(TestCase): def test_update_invalid(self): res = self.client.post( - "/edit/author/%d/update/" % self.author.pk, + "/edit/author/%s/update/" % self.author.pk, {"name": "A" * 101, "slug": "randall-munroe"}, ) self.assertEqual(res.status_code, 200) @@ -278,15 +278,15 @@ class UpdateViewTests(TestCase): def test_update_with_object_url(self): a = Artist.objects.create(name="Rene Magritte") res = self.client.post( - "/edit/artists/%d/update/" % a.pk, {"name": "Rene Magritte"} + "/edit/artists/%s/update/" % a.pk, {"name": "Rene Magritte"} ) self.assertEqual(res.status_code, 302) - self.assertRedirects(res, "/detail/artist/%d/" % a.pk) + self.assertRedirects(res, "/detail/artist/%s/" % a.pk) self.assertQuerySetEqual(Artist.objects.all(), [a]) def test_update_with_redirect(self): res = self.client.post( - "/edit/author/%d/update/redirect/" % self.author.pk, + "/edit/author/%s/update/redirect/" % self.author.pk, {"name": "Randall Munroe (author of xkcd)", "slug": "randall-munroe"}, ) self.assertEqual(res.status_code, 302) @@ -298,7 +298,7 @@ class UpdateViewTests(TestCase): def test_update_with_interpolated_redirect(self): res = self.client.post( - "/edit/author/%d/update/interpolate_redirect/" % self.author.pk, + "/edit/author/%s/update/interpolate_redirect/" % self.author.pk, {"name": "Randall Munroe (author of xkcd)", "slug": "randall-munroe"}, ) self.assertQuerySetEqual( @@ -307,10 +307,10 @@ class UpdateViewTests(TestCase): ) self.assertEqual(res.status_code, 302) pk = Author.objects.first().pk - self.assertRedirects(res, "/edit/author/%d/update/" % pk) + self.assertRedirects(res, "/edit/author/%s/update/" % pk) # Also test with escaped chars in URL res = self.client.post( - "/edit/author/%d/update/interpolate_redirect_nonascii/" % self.author.pk, + "/edit/author/%s/update/interpolate_redirect_nonascii/" % self.author.pk, {"name": "John Doe", "slug": "john-doe"}, ) self.assertEqual(res.status_code, 302) @@ -318,7 +318,7 @@ class UpdateViewTests(TestCase): self.assertRedirects(res, "/%C3%A9dit/author/{}/update/".format(pk)) def test_update_with_special_properties(self): - res = self.client.get("/edit/author/%d/update/special/" % self.author.pk) + res = self.client.get("/edit/author/%s/update/special/" % self.author.pk) self.assertEqual(res.status_code, 200) self.assertIsInstance(res.context["form"], views.AuthorForm) self.assertEqual(res.context["object"], self.author) @@ -327,11 +327,11 @@ class UpdateViewTests(TestCase): self.assertTemplateUsed(res, "generic_views/form.html") res = self.client.post( - "/edit/author/%d/update/special/" % self.author.pk, + "/edit/author/%s/update/special/" % self.author.pk, {"name": "Randall Munroe (author of xkcd)", "slug": "randall-munroe"}, ) self.assertEqual(res.status_code, 302) - self.assertRedirects(res, "/detail/author/%d/" % self.author.pk) + self.assertRedirects(res, "/detail/author/%s/" % self.author.pk) self.assertQuerySetEqual( Author.objects.values_list("name", flat=True), ["Randall Munroe (author of xkcd)"], @@ -344,7 +344,7 @@ class UpdateViewTests(TestCase): ) with self.assertRaisesMessage(ImproperlyConfigured, msg): self.client.post( - "/edit/author/%d/update/naive/" % self.author.pk, + "/edit/author/%s/update/naive/" % self.author.pk, {"name": "Randall Munroe (author of xkcd)", "slug": "randall-munroe"}, ) @@ -379,37 +379,37 @@ class DeleteViewTests(TestCase): ) def test_delete_by_post(self): - res = self.client.get("/edit/author/%d/delete/" % self.author.pk) + res = self.client.get("/edit/author/%s/delete/" % self.author.pk) self.assertEqual(res.status_code, 200) self.assertEqual(res.context["object"], self.author) self.assertEqual(res.context["author"], self.author) self.assertTemplateUsed(res, "generic_views/author_confirm_delete.html") # Deletion with POST - res = self.client.post("/edit/author/%d/delete/" % self.author.pk) + res = self.client.post("/edit/author/%s/delete/" % self.author.pk) self.assertEqual(res.status_code, 302) self.assertRedirects(res, "/list/authors/") self.assertQuerySetEqual(Author.objects.all(), []) def test_delete_by_delete(self): # Deletion with browser compatible DELETE method - res = self.client.delete("/edit/author/%d/delete/" % self.author.pk) + res = self.client.delete("/edit/author/%s/delete/" % self.author.pk) self.assertEqual(res.status_code, 302) self.assertRedirects(res, "/list/authors/") self.assertQuerySetEqual(Author.objects.all(), []) def test_delete_with_redirect(self): - res = self.client.post("/edit/author/%d/delete/redirect/" % self.author.pk) + res = self.client.post("/edit/author/%s/delete/redirect/" % self.author.pk) self.assertEqual(res.status_code, 302) self.assertRedirects(res, "/edit/authors/create/") self.assertQuerySetEqual(Author.objects.all(), []) def test_delete_with_interpolated_redirect(self): res = self.client.post( - "/edit/author/%d/delete/interpolate_redirect/" % self.author.pk + "/edit/author/%s/delete/interpolate_redirect/" % self.author.pk ) self.assertEqual(res.status_code, 302) - self.assertRedirects(res, "/edit/authors/create/?deleted=%d" % self.author.pk) + self.assertRedirects(res, "/edit/authors/create/?deleted=%s" % self.author.pk) self.assertQuerySetEqual(Author.objects.all(), []) # Also test with escaped chars in URL a = Author.objects.create( @@ -422,14 +422,14 @@ class DeleteViewTests(TestCase): self.assertRedirects(res, "/%C3%A9dit/authors/create/?deleted={}".format(a.pk)) def test_delete_with_special_properties(self): - res = self.client.get("/edit/author/%d/delete/special/" % self.author.pk) + res = self.client.get("/edit/author/%s/delete/special/" % self.author.pk) self.assertEqual(res.status_code, 200) self.assertEqual(res.context["object"], self.author) self.assertEqual(res.context["thingy"], self.author) self.assertNotIn("author", res.context) self.assertTemplateUsed(res, "generic_views/confirm_delete.html") - res = self.client.post("/edit/author/%d/delete/special/" % self.author.pk) + res = self.client.post("/edit/author/%s/delete/special/" % self.author.pk) self.assertEqual(res.status_code, 302) self.assertRedirects(res, "/list/authors/") self.assertQuerySetEqual(Author.objects.all(), []) @@ -437,29 +437,29 @@ class DeleteViewTests(TestCase): def test_delete_without_redirect(self): msg = "No URL to redirect to. Provide a success_url." with self.assertRaisesMessage(ImproperlyConfigured, msg): - self.client.post("/edit/author/%d/delete/naive/" % self.author.pk) + self.client.post("/edit/author/%s/delete/naive/" % self.author.pk) def test_delete_with_form_as_post(self): - res = self.client.get("/edit/author/%d/delete/form/" % self.author.pk) + res = self.client.get("/edit/author/%s/delete/form/" % self.author.pk) self.assertEqual(res.status_code, 200) self.assertEqual(res.context["object"], self.author) self.assertEqual(res.context["author"], self.author) self.assertTemplateUsed(res, "generic_views/author_confirm_delete.html") res = self.client.post( - "/edit/author/%d/delete/form/" % self.author.pk, data={"confirm": True} + "/edit/author/%s/delete/form/" % self.author.pk, data={"confirm": True} ) self.assertEqual(res.status_code, 302) self.assertRedirects(res, "/list/authors/") self.assertSequenceEqual(Author.objects.all(), []) def test_delete_with_form_as_post_with_validation_error(self): - res = self.client.get("/edit/author/%d/delete/form/" % self.author.pk) + res = self.client.get("/edit/author/%s/delete/form/" % self.author.pk) self.assertEqual(res.status_code, 200) self.assertEqual(res.context["object"], self.author) self.assertEqual(res.context["author"], self.author) self.assertTemplateUsed(res, "generic_views/author_confirm_delete.html") - res = self.client.post("/edit/author/%d/delete/form/" % self.author.pk) + res = self.client.post("/edit/author/%s/delete/form/" % self.author.pk) self.assertEqual(res.status_code, 200) self.assertEqual(len(res.context_data["form"].errors), 2) self.assertEqual( diff --git a/tests/many_to_one/tests.py b/tests/many_to_one/tests.py index 4d2343e304..193e6e7086 100644 --- a/tests/many_to_one/tests.py +++ b/tests/many_to_one/tests.py @@ -889,7 +889,7 @@ class ManyToOneTests(TestCase): def test_add_remove_set_by_pk_raises(self): usa = Country.objects.create(name="United States") chicago = City.objects.create(name="Chicago") - msg = "'City' instance expected, got %s" % chicago.pk + msg = "'City' instance expected, got %r" % chicago.pk with self.assertRaisesMessage(TypeError, msg): usa.cities.add(chicago.pk) with self.assertRaisesMessage(TypeError, msg): diff --git a/tests/model_forms/test_modelchoicefield.py b/tests/model_forms/test_modelchoicefield.py index 7b086fb182..7f66b5b078 100644 --- a/tests/model_forms/test_modelchoicefield.py +++ b/tests/model_forms/test_modelchoicefield.py @@ -347,11 +347,11 @@ class ModelChoiceFieldTests(TestCase): field.widget.render("name", []), ( "
" - '
' - '
' - '
' "
" ) @@ -393,14 +393,14 @@ class ModelChoiceFieldTests(TestCase): field.widget.render("name", []), """
-
""" % (self.c1.pk, self.c2.pk, self.c3.pk), ) diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index 466674ef64..3d4eb06cf4 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -1650,9 +1650,9 @@ class ModelFormBasicTests(TestCase):
  • """ % (self.c1.pk, self.c2.pk, self.c3.pk), ) diff --git a/tests/model_formsets/tests.py b/tests/model_formsets/tests.py index 4e5c0e39c5..02c928cba2 100644 --- a/tests/model_formsets/tests.py +++ b/tests/model_formsets/tests.py @@ -234,7 +234,7 @@ class ModelFormsetTest(TestCase): '

    ' '' - '

    ' + '

    ' % author2.id, ) self.assertHTMLEqual( @@ -242,7 +242,7 @@ class ModelFormsetTest(TestCase): '

    ' '' - '

    ' + '

    ' % author1.id, ) self.assertHTMLEqual( @@ -292,7 +292,7 @@ class ModelFormsetTest(TestCase): 'value="Arthur Rimbaud" maxlength="100">

    ' '

    ' '' - '

    ' + '

    ' % author2.id, ) self.assertHTMLEqual( @@ -302,7 +302,7 @@ class ModelFormsetTest(TestCase): 'value="Charles Baudelaire" maxlength="100">

    ' '

    ' '' - '

    ' + '

    ' % author1.id, ) self.assertHTMLEqual( @@ -312,7 +312,7 @@ class ModelFormsetTest(TestCase): 'value="Paul Verlaine" maxlength="100">

    ' '

    ' '' - '

    ' + '

    ' % author3.id, ) self.assertHTMLEqual( @@ -604,7 +604,7 @@ class ModelFormsetTest(TestCase): '

    ' '' - '

    ' % hemingway_id, ) self.assertHTMLEqual( @@ -649,7 +649,7 @@ class ModelFormsetTest(TestCase): '

    ' '' - '' '' "

    " % author.id, @@ -659,7 +659,7 @@ class ModelFormsetTest(TestCase): '

    ' '' - '' '

    ' % author.id, @@ -669,7 +669,7 @@ class ModelFormsetTest(TestCase): '

    ' '' - '' '

    ' % author.id, @@ -709,9 +709,9 @@ class ModelFormsetTest(TestCase): '

    ' '' - '' - '

    ' % ( author.id, @@ -723,7 +723,7 @@ class ModelFormsetTest(TestCase): '

    ' '' - '' '

    ' % author.id, @@ -733,7 +733,7 @@ class ModelFormsetTest(TestCase): '

    ' '' - '' '

    ' % author.id, @@ -1216,7 +1216,7 @@ class ModelFormsetTest(TestCase): 'value="Joe Perry" maxlength="100">' '' - '

    ' % owner1.auto_id, ) self.assertHTMLEqual( @@ -1268,8 +1268,8 @@ class ModelFormsetTest(TestCase): '

    ' '

    " '

    ' '

    ' @@ -1289,7 +1289,7 @@ class ModelFormsetTest(TestCase): '

    ' '' - '

    ' % owner1.auto_id, ) @@ -1315,7 +1315,7 @@ class ModelFormsetTest(TestCase): '

    ' '' - '

    ' % owner1.auto_id, ) @@ -1589,7 +1589,7 @@ class ModelFormsetTest(TestCase): '

    ' '' - '' '

    ' % person.id, diff --git a/tests/modeladmin/tests.py b/tests/modeladmin/tests.py index 4a92514e17..f50a557d02 100644 --- a/tests/modeladmin/tests.py +++ b/tests/modeladmin/tests.py @@ -637,8 +637,8 @@ class ModelAdminTests(TestCase): '" % (band2.id, self.band.id), ) @@ -661,7 +661,7 @@ class ModelAdminTests(TestCase): '" % self.band.id, ) diff --git a/tests/serializers/test_data.py b/tests/serializers/test_data.py index 121404a0ef..744c9d1a2b 100644 --- a/tests/serializers/test_data.py +++ b/tests/serializers/test_data.py @@ -170,7 +170,7 @@ def data_compare(testcase, pk, klass, data): testcase.assertEqual( bytes(data), bytes(instance.data), - "Objects with PK=%d not equal; expected '%s' (%s), got '%s' (%s)" + "Objects with PK=%s not equal; expected '%s' (%s), got '%s' (%s)" % ( pk, repr(bytes(data)), @@ -183,7 +183,7 @@ def data_compare(testcase, pk, klass, data): testcase.assertEqual( data, instance.data, - "Objects with PK=%d not equal; expected '%s' (%s), got '%s' (%s)" + "Objects with PK=%s not equal; expected '%s' (%s), got '%s' (%s)" % ( pk, data, diff --git a/tests/serializers/test_natural.py b/tests/serializers/test_natural.py index e5592f97c8..b405dc3e28 100644 --- a/tests/serializers/test_natural.py +++ b/tests/serializers/test_natural.py @@ -44,7 +44,7 @@ def natural_key_serializer_test(self, format): self.assertEqual( obj.data, instance.data, - "Objects with PK=%d not equal; expected '%s' (%s), got '%s' (%s)" + "Objects with PK=%s not equal; expected '%s' (%s), got '%s' (%s)" % ( obj.pk, obj.data, -- cgit v1.3