Skip to content

Commit

Permalink
Update deprecated assertions in tests for python 3.12
Browse files Browse the repository at this point in the history
`assertEquals` should be `assertEqual`

`assertRegexpMatches` should be `assertRegex`

https://docs.python.org/3.12/whatsnew/3.12.html#removed
  • Loading branch information
philgyford committed Jun 20, 2023
1 parent a7c4b17 commit c97eb90
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 64 deletions.
16 changes: 8 additions & 8 deletions tests/core/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DittoViewTests(TestCase):
def test_home_templates(self):
"Overall home page uses the correct templates"
response = self.client.get(reverse("ditto:home"))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "ditto/home.html")
self.assertTemplateUsed(response, "ditto/base.html")

Expand Down Expand Up @@ -140,7 +140,7 @@ def test_home_no_twitter(self):
# def test_tag_list_templates(self):
# "Uses the correct templates"
# response = self.client.get(reverse('ditto:tag_list'))
# self.assertEquals(response.status_code, 200)
# self.assertEqual(response.status_code, 200)
# self.assertTemplateUsed(response, 'ditto/tag_list.html')
# self.assertTemplateUsed(response, 'ditto/base.html')

Expand All @@ -150,7 +150,7 @@ def test_home_no_twitter(self):
# bookmark.tags.set(['fish'])
# response = self.client.get(reverse('ditto:tag_detail',
# kwargs={'slug': 'fish'}))
# self.assertEquals(response.status_code, 200)
# self.assertEqual(response.status_code, 200)
# self.assertTemplateUsed(response, 'ditto/tag_detail.html')
# self.assertTemplateUsed(response, 'ditto/base.html')

Expand Down Expand Up @@ -238,23 +238,23 @@ def test_no_app(self):

def test_success_flickr_photos(self):
response = self.client.get(self.make_url("flickr", "photos"))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)

def test_success_lastfm(self):
response = self.client.get(self.make_url("lastfm", "listens"))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)

def test_success_pinboard(self):
response = self.client.get(self.make_url("pinboard", "bookmarks"))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)

def test_success_twitter_tweets(self):
response = self.client.get(self.make_url("twitter", "tweets"))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)

def test_success_twitter_favorites(self):
response = self.client.get(self.make_url("twitter", "likes"))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)

def test_day_templates(self):
"Day archive page uses the correct templates"
Expand Down
4 changes: 2 additions & 2 deletions tests/flickr/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,15 +508,15 @@ def test_remote_original_url(self):

def test_medium_url(self):
"Has a different format to most other image sizes."
self.assertRegexpMatches(
self.assertRegex(
self.photo.medium_url,
r"CACHE/images/flickr/34/56/123456N01/photos/2015/08/14/example.[^\.]+\.jpg", # noqa: E501
)

def test_image_urls(self):
"""Test all but the Original and Medium image URL properties."""
for size, prop in self.photo_sizes.items():
self.assertRegexpMatches(
self.assertRegex(
getattr(self.photo, prop),
r"CACHE/images/flickr/34/56/123456N01/photos/2015/08/14/example.[^\.]+\.jpg", # noqa: E501
)
Expand Down
28 changes: 14 additions & 14 deletions tests/flickr/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class HomeViewTests(TestCase):
def test_home_templates(self):
"The Flickr home page uses the correct templates"
response = self.client.get(reverse("flickr:home"))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "flickr/home.html")
self.assertTemplateUsed(response, "flickr/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand Down Expand Up @@ -95,7 +95,7 @@ def test_user_detail_templates(self):
response = self.client.get(
reverse("flickr:user_detail", kwargs={"nsid": account.user.nsid})
)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "flickr/user_detail.html")
self.assertTemplateUsed(response, "flickr/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand Down Expand Up @@ -210,7 +210,7 @@ def test_photo_detail_templates(self):
kwargs={"nsid": account.user.nsid, "flickr_id": photos[1].flickr_id},
)
)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "flickr/photo_detail.html")
self.assertTemplateUsed(response, "flickr/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand Down Expand Up @@ -308,7 +308,7 @@ def test_tag_list_templates(self):
"Uses the correct templates"
# Shouldn't need any photos to exist.
response = self.client.get(reverse("flickr:tag_list"))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "flickr/tag_list.html")
self.assertTemplateUsed(response, "flickr/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand All @@ -335,7 +335,7 @@ def test_tag_detail_templates(self):
response = self.client.get(
reverse("flickr:tag_detail", kwargs={"slug": "fish"})
)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "flickr/tag_detail.html")
self.assertTemplateUsed(response, "flickr/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand Down Expand Up @@ -398,12 +398,12 @@ def test_tag_detail_privacy(self):
response = self.client.get(
reverse("flickr:tag_detail", kwargs={"slug": "carp"})
)
self.assertEquals(response.status_code, 404)
self.assertEqual(response.status_code, 404)

def test_tag_detail_fails(self):
"Returns a 404 if a non-existent tag's page is requested"
response = self.client.get(reverse("flickr:tag_detail", kwargs={"slug": "bob"}))
self.assertEquals(response.status_code, 404)
self.assertEqual(response.status_code, 404)

# USER TAG DETAIL

Expand All @@ -415,7 +415,7 @@ def test_user_tag_detail_templates(self):
kwargs={"nsid": self.carp_photo.user.nsid, "tag_slug": "fish"},
)
)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "flickr/user_tag_detail.html")
self.assertTemplateUsed(response, "flickr/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand Down Expand Up @@ -498,7 +498,7 @@ def test_user_tag_detail_privacy(self):
kwargs={"nsid": self.carp_photo.user.nsid, "tag_slug": "carp"},
)
)
self.assertEquals(response.status_code, 404)
self.assertEqual(response.status_code, 404)

def test_user_tag_detail_fails_1(self):
"Returns a 404 if a non-existent user is requested"
Expand All @@ -508,7 +508,7 @@ def test_user_tag_detail_fails_1(self):
kwargs={"nsid": "99999999999@N99", "tag_slug": "fish"},
)
)
self.assertEquals(response.status_code, 404)
self.assertEqual(response.status_code, 404)

def test_user_tag_detail_fails_2(self):
"Returns a 404 if a non-existent tag is requested"
Expand All @@ -518,7 +518,7 @@ def test_user_tag_detail_fails_2(self):
kwargs={"nsid": self.carp_photo.user.nsid, "tag_slug": "mammal"},
)
)
self.assertEquals(response.status_code, 404)
self.assertEqual(response.status_code, 404)


class PhotosetViewTests(TestCase):
Expand Down Expand Up @@ -551,7 +551,7 @@ def setUp(self):
def test_photoset_list_templates(self):
"Uses the correct templates"
response = self.client.get(reverse("flickr:photoset_list"))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "flickr/photoset_list.html")
self.assertTemplateUsed(response, "flickr/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand All @@ -571,7 +571,7 @@ def test_user_photoset_list_templates(self):
response = self.client.get(
reverse("flickr:user_photoset_list", kwargs={"nsid": self.user_1.nsid})
)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "flickr/user_photoset_list.html")
self.assertTemplateUsed(response, "flickr/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand All @@ -597,7 +597,7 @@ def test_photoset_detail_templates(self):
},
)
)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "flickr/photoset_detail.html")
self.assertTemplateUsed(response, "flickr/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand Down
30 changes: 15 additions & 15 deletions tests/lastfm/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_templates(self):
},
)
)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "lastfm/album_detail.html")
self.assertTemplateUsed(response, "lastfm/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand All @@ -57,14 +57,14 @@ def test_404s(self):
kwargs={"artist_slug": self.artist.slug, "album_slug": "Transformer"},
)
)
self.assertEquals(response.status_code, 404)
self.assertEqual(response.status_code, 404)


class AlbumListViewTests(TestCase):
def test_templates(self):
"Uses the correct templates"
response = self.client.get(reverse("lastfm:album_list"))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "lastfm/album_list.html")
self.assertTemplateUsed(response, "lastfm/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand Down Expand Up @@ -149,7 +149,7 @@ def test_templates(self):
response = self.client.get(
reverse("lastfm:artist_albums", kwargs={"artist_slug": self.artist.slug})
)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "lastfm/artist_albums.html")
self.assertTemplateUsed(response, "lastfm/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand All @@ -167,7 +167,7 @@ def test_404s(self):
response = self.client.get(
reverse("lastfm:artist_albums", kwargs={"artist_slug": "Looper"})
)
self.assertEquals(response.status_code, 404)
self.assertEqual(response.status_code, 404)


class ArtistDetailViewTests(TestCase):
Expand All @@ -179,7 +179,7 @@ def test_templates(self):
response = self.client.get(
reverse("lastfm:artist_detail", kwargs={"artist_slug": self.artist.slug})
)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "lastfm/artist_detail.html")
self.assertTemplateUsed(response, "lastfm/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand All @@ -197,14 +197,14 @@ def test_404s(self):
response = self.client.get(
reverse("lastfm:artist_detail", kwargs={"artist_slug": "Looper"})
)
self.assertEquals(response.status_code, 404)
self.assertEqual(response.status_code, 404)


class ArtistListViewTests(TestCase):
def test_templates(self):
"Uses the correct templates"
response = self.client.get(reverse("lastfm:artist_list"))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "lastfm/artist_list.html")
self.assertTemplateUsed(response, "lastfm/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand Down Expand Up @@ -284,7 +284,7 @@ class HomeViewTests(TestCase):
def test_templates(self):
"Uses the correct templates"
response = self.client.get(reverse("lastfm:home"))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "lastfm/home.html")
self.assertTemplateUsed(response, "lastfm/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand All @@ -306,7 +306,7 @@ class ScrobbleListViewTests(TestCase):
def test_templates(self):
"Uses the correct templates"
response = self.client.get(reverse("lastfm:scrobble_list"))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "lastfm/scrobble_list.html")
self.assertTemplateUsed(response, "lastfm/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand Down Expand Up @@ -336,7 +336,7 @@ def test_templates(self):
},
)
)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "lastfm/track_detail.html")
self.assertTemplateUsed(response, "lastfm/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand All @@ -363,14 +363,14 @@ def test_404s(self):
kwargs={"artist_slug": self.artist.slug, "track_slug": "Viscious"},
)
)
self.assertEquals(response.status_code, 404)
self.assertEqual(response.status_code, 404)


class TrackListViewTests(TestCase):
def test_templates(self):
"Uses the correct templates"
response = self.client.get(reverse("lastfm:track_list"))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "lastfm/track_list.html")
self.assertTemplateUsed(response, "lastfm/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand Down Expand Up @@ -491,7 +491,7 @@ def test_templates(self):
response = self.client.get(
reverse("lastfm:%s" % self.view_name, kwargs={"username": "bob"})
)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "lastfm/%s.html" % self.view_name)
self.assertTemplateUsed(response, "lastfm/base.html")
self.assertTemplateUsed(response, "ditto/base.html")
Expand All @@ -514,7 +514,7 @@ def test_404s(self):
response = self.client.get(
reverse("lastfm:%s" % self.view_name, kwargs={"username": "thelma"})
)
self.assertEquals(response.status_code, 404)
self.assertEqual(response.status_code, 404)


class UserDetailViewTestCase(UserCommonTests, TestCase):
Expand Down
Loading

0 comments on commit c97eb90

Please sign in to comment.