Skip to content

Commit

Permalink
Satisfy ruff again
Browse files Browse the repository at this point in the history
  • Loading branch information
philgyford committed Jan 14, 2025
1 parent c6a37c8 commit 349f344
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions tests/flickr/test_fetch_fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ def test_calls_save_user_correctly(self, save_user, fetch_avatar):
def test_downloads_and_saves_avatar(self, download):
"Should call download() and save avatar when fetching user."
# Make a temporary file, like download() would make:
jpg = tempfile.NamedTemporaryFile()
temp_filepath = jpg.name
download.return_value = temp_filepath
with tempfile.NamedTemporaryFile() as jpg:
temp_filepath = jpg.name
download.return_value = temp_filepath

self.expect_response("people.getInfo")
UserFetcher(account=self.account).fetch(nsid="35034346050@N01")
Expand Down
12 changes: 6 additions & 6 deletions tests/flickr/test_fetch_filesfetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ def test_raises_error_if_download_fails(self, download):
@patch.object(filedownloader, "download")
def test_saves_downloaded_photo_file(self, download):
# Make a temporary file, like download() would make:
jpg = tempfile.NamedTemporaryFile()
temp_filepath = jpg.name
download.return_value = temp_filepath
with tempfile.NamedTemporaryFile() as jpg:
temp_filepath = jpg.name
download.return_value = temp_filepath

self.fetcher._fetch_and_save_file(self.photo_2, "photo")
nsid = self.photo_2.user.nsid
Expand All @@ -170,9 +170,9 @@ def test_saves_downloaded_photo_file(self, download):
@patch.object(filedownloader, "download")
def test_saves_downloaded_video_file(self, download):
# Make a temporary file, like download() would make:
video = tempfile.NamedTemporaryFile()
temp_filepath = video.name
download.return_value = temp_filepath
with tempfile.NamedTemporaryFile() as video:
temp_filepath = video.name
download.return_value = temp_filepath

self.fetcher._fetch_and_save_file(self.video_2, "video")
nsid = self.video_2.user.nsid
Expand Down
12 changes: 6 additions & 6 deletions tests/twitter/test_fetch_fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,9 +969,9 @@ def test_raises_error_if_download_fails(self, download):
@patch.object(filedownloader, "download")
def test_saves_downloaded_image_file(self, download):
# Make a temporary file, like download() would make:
jpg = tempfile.NamedTemporaryFile()
temp_filepath = jpg.name
download.return_value = temp_filepath
with tempfile.NamedTemporaryFile() as jpg:
temp_filepath = jpg.name
download.return_value = temp_filepath

FetchFiles()._fetch_and_save_file(self.image, "image")
self.assertEqual(
Expand All @@ -986,9 +986,9 @@ def test_saves_downloaded_image_file(self, download):
@patch.object(filedownloader, "download")
def test_saves_downloaded_mp4_file(self, download):
# Make a temporary file, like download() would make:
mp4 = tempfile.NamedTemporaryFile()
temp_filepath = mp4.name
download.return_value = temp_filepath
with tempfile.NamedTemporaryFile() as mp4:
temp_filepath = mp4.name
download.return_value = temp_filepath

FetchFiles()._fetch_and_save_file(self.animated_gif, "mp4")
self.assertEqual(
Expand Down
6 changes: 3 additions & 3 deletions tests/twitter/test_fetch_savers.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,9 @@ def test_calls_fetch_and_save_avatar(self, fetch_avatar, download):
def test_downloads_and_saves_avatar(self, download):
"Should call download() and save avatar."
# Make a temporary file, like download() would make:
jpg = tempfile.NamedTemporaryFile()
temp_filepath = jpg.name
download.return_value = temp_filepath
with tempfile.NamedTemporaryFile() as jpg:
temp_filepath = jpg.name
download.return_value = temp_filepath

user_data = self.make_user_data()
saved_user = UserSaver().save_user(user_data, datetime_now())
Expand Down
8 changes: 4 additions & 4 deletions tests/twitter/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def add_response(self, body, call, status=200):
def test_str_1(self):
"Has the correct string represntation when it has no user"
account = AccountFactory(user=None)
self.assertEqual(account.__str__(), "%d" % account.pk)
self.assertEqual(account.__str__(), f"{account.pk}")

def test_str_2(self):
"Has the correct string represntation when it has a user"
Expand Down Expand Up @@ -184,7 +184,7 @@ class PhotoTestCase(TestCase):

def test_str(self):
photo = PhotoFactory()
self.assertEqual(photo.__str__(), "Photo %d" % photo.id)
self.assertEqual(photo.__str__(), f"Photo {photo.id}")

def test_media_type(self):
photo = PhotoFactory()
Expand Down Expand Up @@ -301,7 +301,7 @@ class VideoTestCase(TestCase):

def test_str(self):
video = VideoFactory()
self.assertEqual(video.__str__(), "Video %d" % video.id)
self.assertEqual(video.__str__(), f"Video {video.id}")

def test_media_type(self):
video = VideoFactory()
Expand Down Expand Up @@ -362,7 +362,7 @@ class AnimatedGifTestCase(TestCase):

def test_str(self):
gif = AnimatedGifFactory()
self.assertEqual(gif.__str__(), "Animated GIF %d" % gif.id)
self.assertEqual(gif.__str__(), f"Animated GIF {gif.id}")

def test_media_type(self):
gif = AnimatedGifFactory()
Expand Down

0 comments on commit 349f344

Please sign in to comment.