From 67f900bb769bffe3faebac1a9e7c6b24f4b7c15a Mon Sep 17 00:00:00 2001 From: John William Ruth Miller Date: Thu, 12 Dec 2024 22:34:18 -0800 Subject: [PATCH] Fix relative import in tests --- tests/test_album.py | 32 +++++------ tests/test_api.py | 58 ++++++++++---------- tests/test_artist.py | 41 ++++++-------- tests/test_base.py | 2 +- tests/test_genius.py | 26 ++++----- tests/test_public_methods.py | 102 +++++++++++++++++------------------ tests/test_song.py | 46 ++++++++-------- tests/test_utils.py | 20 +++---- 8 files changed, 156 insertions(+), 171 deletions(-) diff --git a/tests/test_album.py b/tests/test_album.py index 0e9c872e..51e1f853 100644 --- a/tests/test_album.py +++ b/tests/test_album.py @@ -2,7 +2,7 @@ import os import warnings -from . import genius +from tests import genius from lyricsgenius.types import Album @@ -15,10 +15,7 @@ def setUpClass(cls): cls.album_name = "The Party" cls.artist_name = "Andy Shauf" cls.num_tracks = 10 - cls.album = genius.search_album( - cls.album_name, - cls.artist_name - ) + cls.album = genius.search_album(cls.album_name, cls.artist_name) def test_type(self): self.assertIsInstance(self.album, Album) @@ -33,13 +30,12 @@ def test_tracks(self): self.assertEqual(len(self.album.tracks), self.num_tracks) def test_saving_json_file(self): - print('\n') - extension = 'json' + print("\n") + extension = "json" msg = "Could not save {} file.".format(extension) - expected_filename = ('Lyrics_' - + self.album.name.replace(' ', '') - + '.' - + extension) + expected_filename = ( + "Lyrics_" + self.album.name.replace(" ", "") + "." + extension + ) # Remove the test file if it already exists if os.path.isfile(expected_filename): @@ -57,13 +53,12 @@ def test_saving_json_file(self): os.remove(expected_filename) def test_saving_txt_file(self): - print('\n') - extension = 'txt' + print("\n") + extension = "txt" msg = "Could not save {} file.".format(extension) - expected_filename = ('Lyrics_' - + self.album.name.replace(' ', '') - + '.' - + extension) + expected_filename = ( + "Lyrics_" + self.album.name.replace(" ", "") + "." + extension + ) # Remove the test file if it already exists if os.path.isfile(expected_filename): @@ -75,8 +70,7 @@ def test_saving_txt_file(self): # Test overwriting txt file (now that file is written) try: - self.album.save_lyrics( - extension=extension, overwrite=True) + self.album.save_lyrics(extension=extension, overwrite=True) except Exception: self.fail("Failed {} overwrite test".format(extension)) os.remove(expected_filename) diff --git a/tests/test_api.py b/tests/test_api.py index 1b173d9f..26ab571c 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1,7 +1,7 @@ import unittest -from . import genius +from tests import genius class TestAPI(unittest.TestCase): @@ -11,8 +11,10 @@ def setUpClass(cls): print("\n---------------------\nSetting up API tests...\n") def test_account(self): - msg = ("No user detail was returned. " - "Are you sure you're using a user access token?") + msg = ( + "No user detail was returned. " + "Are you sure you're using a user access token?" + ) r = genius.account() self.assertTrue("user" in r, msg) @@ -20,54 +22,52 @@ def test_annotation(self): msg = "Returned annotation API path is different than expected." id_ = 10225840 r = genius.annotation(id_) - real = r['annotation']['api_path'] - expected = '/annotations/10225840' + real = r["annotation"]["api_path"] + expected = "/annotations/10225840" self.assertEqual(real, expected, msg) def test_manage_annotation(self): - example_text = 'The annotation' + example_text = "The annotation" new_annotation = genius.create_annotation( - example_text, - 'https://example.com', - 'illustrative examples', - title='test')['annotation'] - msg = 'Annotation text did not match the one that was passed.' - self.assertEqual(new_annotation['body']['plain'], example_text, msg) + example_text, "https://example.com", "illustrative examples", title="test" + )["annotation"] + msg = "Annotation text did not match the one that was passed." + self.assertEqual(new_annotation["body"]["plain"], example_text, msg) try: - example_text_two = 'Updated annotation' + example_text_two = "Updated annotation" r = genius.update_annotation( - new_annotation['id'], + new_annotation["id"], example_text_two, - 'https://example.com', - 'illustrative examples', - title='test' - )['annotation'] - msg = 'Updated annotation text did not match the one that was passed.' - self.assertEqual(r['body']['plain'], example_text_two, msg) + "https://example.com", + "illustrative examples", + title="test", + )["annotation"] + msg = "Updated annotation text did not match the one that was passed." + self.assertEqual(r["body"]["plain"], example_text_two, msg) r = genius.upvote_annotation(11828417) - msg = 'Upvote was not registered.' + msg = "Upvote was not registered." self.assertTrue(r is not None, msg) r = genius.downvote_annotation(11828417) - msg = 'Downvote was not registered.' + msg = "Downvote was not registered." self.assertTrue(r is not None, msg) r = genius.unvote_annotation(11828417) - msg = 'Vote was not removed.' + msg = "Vote was not removed." self.assertTrue(r is not None, msg) finally: - msg = 'Annotation was not deleted.' - r = genius.delete_annotation(new_annotation['id']) + msg = "Annotation was not deleted." + r = genius.delete_annotation(new_annotation["id"]) self.assertEqual(r, 204, msg) def test_referents_web_page(self): msg = "Returned referent API path is different than expected." id_ = 10347 r = genius.referents(web_page_id=id_) - real = r['referents'][0]['api_path'] - expected = '/referents/11828416' + real = r["referents"][0]["api_path"] + expected = "/referents/11828416" self.assertTrue(real == expected, msg) def test_referents_no_inputs(self): @@ -84,6 +84,6 @@ def test_web_page(self): msg = "Returned web page API path is different than expected." url = "https://docs.genius.com" r = genius.web_page(raw_annotatable_url=url) - real = r['web_page']['api_path'] - expected = '/web_pages/10347' + real = r["web_page"]["api_path"] + expected = "/web_pages/10347" self.assertEqual(real, expected, msg) diff --git a/tests/test_artist.py b/tests/test_artist.py index 42c852b3..53e0d2d1 100644 --- a/tests/test_artist.py +++ b/tests/test_artist.py @@ -1,7 +1,7 @@ import unittest import os -from . import genius +from tests import genius from lyricsgenius.types import Artist from lyricsgenius.utils import sanitize_filename @@ -15,8 +15,7 @@ def setUpClass(cls): cls.artist_name = "The Beatles" cls.new_song = "Paperback Writer" cls.max_songs = 2 - cls.artist = genius.search_artist( - cls.artist_name, max_songs=cls.max_songs) + cls.artist = genius.search_artist(cls.artist_name, max_songs=cls.max_songs) def test_artist(self): msg = "The returned object is not an instance of the Artist class." @@ -56,31 +55,27 @@ def test_add_song_from_different_artist(self): def test_artist_with_includes_features(self): # The artist did not get songs returned that they were featured in. name = "Swae Lee" - result = genius.search_artist( - name, - max_songs=1, - include_features=True) + result = genius.search_artist(name, max_songs=1, include_features=True) result = result.songs[0].artist self.assertNotEqual(result, name) def determine_filenames(self, extension): expected_filenames = [] for song in self.artist.songs: - fn = "lyrics_{name}_{song}.{ext}".format(name=self.artist.name, - song=song.title, - ext=extension) + fn = "lyrics_{name}_{song}.{ext}".format( + name=self.artist.name, song=song.title, ext=extension + ) fn = sanitize_filename(fn.lower().replace(" ", "")) expected_filenames.append(fn) return expected_filenames def test_saving_json_file(self): - print('\n') - extension = 'json' + print("\n") + extension = "json" msg = "Could not save {} file.".format(extension) - expected_filename = ('Lyrics_' - + self.artist.name.replace(' ', '') - + '.' - + extension) + expected_filename = ( + "Lyrics_" + self.artist.name.replace(" ", "") + "." + extension + ) # Remove the test file if it already exists if os.path.isfile(expected_filename): @@ -98,13 +93,12 @@ def test_saving_json_file(self): os.remove(expected_filename) def test_saving_txt_file(self): - print('\n') - extension = 'txt' + print("\n") + extension = "txt" msg = "Could not save {} file.".format(extension) - expected_filename = ('Lyrics_' - + self.artist.name.replace(' ', '') - + '.' - + extension) + expected_filename = ( + "Lyrics_" + self.artist.name.replace(" ", "") + "." + extension + ) # Remove the test file if it already exists if os.path.isfile(expected_filename): @@ -116,8 +110,7 @@ def test_saving_txt_file(self): # Test overwriting txt file (now that file is written) try: - self.artist.save_lyrics( - extension=extension, overwrite=True) + self.artist.save_lyrics(extension=extension, overwrite=True) except Exception: self.fail("Failed {} overwrite test".format(extension)) os.remove(expected_filename) diff --git a/tests/test_base.py b/tests/test_base.py index e20adef7..8e6f7357 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -2,7 +2,7 @@ from requests.exceptions import HTTPError -from . import genius +from tests import genius class TestAPIBase(unittest.TestCase): diff --git a/tests/test_genius.py b/tests/test_genius.py index 87d31a03..f9c4429b 100644 --- a/tests/test_genius.py +++ b/tests/test_genius.py @@ -1,6 +1,6 @@ import unittest -from . import genius +from tests import genius class TestEndpoints(unittest.TestCase): @@ -11,12 +11,12 @@ def setUpClass(cls): cls.search_term = "Ezra Furman" cls.song_title_only = "99 Problems" - cls.tag = genius.tag('pop') + cls.tag = genius.tag("pop") def test_search_song(self): artist = "Jay-Z" # Empty response - response = genius.search_song('') + response = genius.search_song("") self.assertIsNone(response) # Pass no title and ID @@ -53,25 +53,25 @@ def test_song_annotations(self): def test_tag_results(self): r = self.tag - self.assertEqual(r['next_page'], 2) - self.assertEqual(len(r['hits']), 20) + self.assertEqual(r["next_page"], 2) + self.assertEqual(len(r["hits"]), 20) def test_tag_first_result(self): - artists = ['Luis Fonsi', 'Daddy Yankee'] - featured_artists = ['Justin Bieber'] + artists = ["Luis Fonsi", "Daddy Yankee"] + featured_artists = ["Justin Bieber"] song_title = "Despacito (Remix)" title_with_artists = ( "Despacito (Remix) by Luis Fonsi & Daddy Yankee (Ft. Justin Bieber)" ) url = "https://genius.com/Luis-fonsi-and-daddy-yankee-despacito-remix-lyrics" - first_song = self.tag['hits'][0] + first_song = self.tag["hits"][0] - self.assertEqual(artists, first_song['artists']) - self.assertEqual(featured_artists, first_song['featured_artists']) - self.assertEqual(song_title, first_song['title']) - self.assertEqual(title_with_artists, first_song['title_with_artists']) - self.assertEqual(url, first_song['url']) + self.assertEqual(artists, first_song["artists"]) + self.assertEqual(featured_artists, first_song["featured_artists"]) + self.assertEqual(song_title, first_song["title"]) + self.assertEqual(title_with_artists, first_song["title_with_artists"]) + self.assertEqual(url, first_song["url"]) class TestLyrics(unittest.TestCase): diff --git a/tests/test_public_methods.py b/tests/test_public_methods.py index 3b87b7e3..c2b8b3a1 100644 --- a/tests/test_public_methods.py +++ b/tests/test_public_methods.py @@ -2,7 +2,7 @@ from lyricsgenius import PublicAPI -from . import genius +from tests import genius client = PublicAPI() @@ -19,7 +19,7 @@ def setUpClass(cls): def test_album(self): msg = "Album ID did not match." r = client.album(self.album_id) - self.assertEqual(r['album']['id'], self.album_id, msg) + self.assertEqual(r["album"]["id"], self.album_id, msg) def test_albums_charts(self): msg = "Album charts were empty." @@ -58,7 +58,7 @@ def setUpClass(cls): def test_annotation(self): msg = "annotation ID did not match." r = client.annotation(self.annotation_id) - self.assertEqual(r['annotation']['id'], self.annotation_id, msg) + self.assertEqual(r["annotation"]["id"], self.annotation_id, msg) def test_annotation_edits(self): msg = "annotation edits were empty." @@ -82,7 +82,7 @@ def setUpClass(cls): def test_article(self): msg = "article ID did not match." r = client.article(self.article_id) - self.assertEqual(r['article']['id'], self.article_id, msg) + self.assertEqual(r["article"]["id"], self.article_id, msg) def test_article_comments(self): msg = "article comments were empty." @@ -105,7 +105,7 @@ def setUpClass(cls): def test_artist(self): r = client.artist(self.artist_id) - self.assertEqual(r['artist']['id'], self.artist_id) + self.assertEqual(r["artist"]["id"], self.artist_id) def test_artist_activity(self): r = client.artist_activity(self.artist_id) @@ -132,7 +132,7 @@ def test_artist_songs(self): self.assertTrue("songs" in r) def test_search_artist_songs(self): - r = client.search_artist_songs(self.artist_id, 'test') + r = client.search_artist_songs(self.artist_id, "test") self.assertTrue("songs" in r) @@ -155,15 +155,15 @@ class TestDiscussionMethods(unittest.TestCase): def setUpClass(cls): print("\n---------------------\nSetting up discussion methods tests...\n") -# cls.discussion_id = 123 -# -# def test_discussion(self): -# r = client.discussion(self.discussion_id) -# self.assertEqual(r['discussion']['id'], self.discussion_id) -# -# def test_discussion_replies(self): -# r = client.discussion_replies(self.discussion_id) -# self.assertTrue("forum_posts" in r) + # cls.discussion_id = 123 + # + # def test_discussion(self): + # r = client.discussion(self.discussion_id) + # self.assertEqual(r['discussion']['id'], self.discussion_id) + # + # def test_discussion_replies(self): + # r = client.discussion_replies(self.discussion_id) + # self.assertTrue("forum_posts" in r) def test_discussions(self): r = client.discussions() @@ -195,7 +195,7 @@ def setUpClass(cls): def test_questions(self): r = client.questions(self.album_id) - self.assertIsNotNone(r.get('questions')) + self.assertIsNotNone(r.get("questions")) class TestReferentMethods(unittest.TestCase): @@ -209,12 +209,12 @@ def setUpClass(cls): def test_referent(self): r = client.referent(self.referent_ids) - self.assertTrue(str(self.referent_ids[0]) in r['referents']) - self.assertTrue(str(self.referent_ids[1]) in r['referents']) + self.assertTrue(str(self.referent_ids[0]) in r["referents"]) + self.assertTrue(str(self.referent_ids[1]) in r["referents"]) def test_referents(self): r = client.referents(web_page_id=self.web_page_id) - self.assertIsNotNone(r.get('referents')) + self.assertIsNotNone(r.get("referents")) class TestSearchMethods(unittest.TestCase): @@ -223,43 +223,43 @@ class TestSearchMethods(unittest.TestCase): def setUpClass(cls): print("\n---------------------\nSetting up search methods tests...\n") - cls.search_term = 'test' + cls.search_term = "test" def test_search(self): r = client.search(self.search_term) - self.assertIsNotNone(r['hits']) + self.assertIsNotNone(r["hits"]) def test_search_albums(self): r = client.search_albums(self.search_term) - self.assertEqual(r['sections'][0]['type'], 'album') + self.assertEqual(r["sections"][0]["type"], "album") def test_search_articles(self): r = client.search_articles(self.search_term) - self.assertEqual(r['sections'][0]['type'], 'article') + self.assertEqual(r["sections"][0]["type"], "article") def test_search_artists(self): r = client.search_artists(self.search_term) - self.assertEqual(r['sections'][0]['type'], 'artist') + self.assertEqual(r["sections"][0]["type"], "artist") def test_search_lyrics(self): r = client.search_lyrics(self.search_term) - self.assertEqual(r['sections'][0]['type'], 'lyric') + self.assertEqual(r["sections"][0]["type"], "lyric") def test_search_songs(self): r = client.search_songs(self.search_term) - self.assertEqual(r['sections'][0]['type'], 'song') + self.assertEqual(r["sections"][0]["type"], "song") def test_search_users(self): r = client.search_users(self.search_term) - self.assertEqual(r['sections'][0]['type'], 'user') + self.assertEqual(r["sections"][0]["type"], "user") def test_search_videos(self): r = client.search_videos(self.search_term) - self.assertEqual(r['sections'][0]['type'], 'video') + self.assertEqual(r["sections"][0]["type"], "video") def test_search_all(self): r = client.search_all(self.search_term) - self.assertEqual(r['sections'][0]['type'], 'top_hit') + self.assertEqual(r["sections"][0]["type"], "top_hit") class TestSongMethods(unittest.TestCase): @@ -272,7 +272,7 @@ def setUpClass(cls): def test_song(self): r = client.song(self.song_id) - self.assertEqual(r['song']['id'], self.song_id) + self.assertEqual(r["song"]["id"], self.song_id) def test_song_activity(self): r = client.song_activity(self.song_id) @@ -297,7 +297,7 @@ def setUpClass(cls): def test_user(self): r = client.user(self.user_id) - self.assertEqual(r['user']['id'], self.user_id) + self.assertEqual(r["user"]["id"], self.user_id) def test_user_accomplishments(self): r = client.user_accomplishments(self.user_id) @@ -317,38 +317,38 @@ def test_user_contributions(self): def test_user_annotations(self): r = client.user_annotations(self.user_id) - type = r['contribution_groups'][0]['contribution_type'] - self.assertEqual(type, 'annotation') + type = r["contribution_groups"][0]["contribution_type"] + self.assertEqual(type, "annotation") def test_user_articles(self): r = client.user_articles(self.user_id) - type = r['contribution_groups'][0]['contribution_type'] - self.assertEqual(type, 'article') + type = r["contribution_groups"][0]["contribution_type"] + self.assertEqual(type, "article") def test_user_pyongs(self): r = client.user_pyongs(self.user_id) - type = r['contribution_groups'][0]['contribution_type'] - self.assertEqual(type, 'pyong') + type = r["contribution_groups"][0]["contribution_type"] + self.assertEqual(type, "pyong") def test_user_questions_and_answers(self): r = client.user_questions_and_answers(self.user_id) - type = r['contribution_groups'][0]['contribution_type'] - self.assertEqual(type, 'answer') + type = r["contribution_groups"][0]["contribution_type"] + self.assertEqual(type, "answer") def test_user_suggestions(self): r = client.user_suggestions(self.user_id) - type = r['contribution_groups'][0]['contribution_type'] - self.assertEqual(type, 'comment') + type = r["contribution_groups"][0]["contribution_type"] + self.assertEqual(type, "comment") def test_user_transcriptions(self): r = client.user_transcriptions(self.user_id) - type = r['contribution_groups'][0]['contribution_type'] - self.assertEqual(type, 'song') + type = r["contribution_groups"][0]["contribution_type"] + self.assertEqual(type, "song") def test_user_unreviewed(self): r = client.user_unreviewed(self.user_id) - type = r['contribution_groups'][0]['contribution_type'] - self.assertEqual(type, 'annotation') + type = r["contribution_groups"][0]["contribution_type"] + self.assertEqual(type, "annotation") class TestVideoMethods(unittest.TestCase): @@ -361,7 +361,7 @@ def setUpClass(cls): def test_video(self): r = client.video(self.video_id) - self.assertEqual(r['video']['id'], self.video_id) + self.assertEqual(r["video"]["id"], self.video_id) def test_videos(self): r = client.videos(video_id=self.video_id, series=True) @@ -385,20 +385,20 @@ def setUpClass(cls): # self.assertTrue("line_item" in r) def test_page_data_album(self): - album_path = '/albums/Eminem/Music-to-be-murdered-by' + album_path = "/albums/Eminem/Music-to-be-murdered-by" page_data = genius.page_data(album=album_path) - self.assertTrue('page_data' in page_data) + self.assertTrue("page_data" in page_data) def test_page_data_song(self): artist = client.artist(1665) - artist_slug = artist['artist']['slug'] + artist_slug = artist["artist"]["slug"] song = genius.song(4558484) - song_path = song['song']['path'] + song_path = song["song"]["path"] page_data = genius.page_data(artist=artist_slug, song=song_path) - self.assertTrue('page_data' in page_data) + self.assertTrue("page_data" in page_data) def test_voters(self): r = client.voters(annotation_id=self.annotation_id) diff --git a/tests/test_song.py b/tests/test_song.py index 3807a4e8..486df731 100644 --- a/tests/test_song.py +++ b/tests/test_song.py @@ -1,7 +1,7 @@ import os import unittest -from . import genius +from tests import genius from lyricsgenius.types import Song from lyricsgenius.utils import clean_str @@ -12,10 +12,10 @@ class TestSong(unittest.TestCase): def setUpClass(cls): print("\n---------------------\nSetting up Song tests...\n") - cls.artist_name = 'Andy Shauf' - cls.song_title = 'begin again' # Lowercase is intentional - cls.album = 'The Party' - cls.year = '2016-05-20' + cls.artist_name = "Andy Shauf" + cls.song_title = "begin again" # Lowercase is intentional + cls.album = "The Party" + cls.year = "2016-05-20" cls.song = genius.search_song(cls.song_title, cls.artist_name) genius.remove_section_headers = True cls.song_trimmed = genius.search_song(cls.song_title, cls.artist_name) @@ -26,30 +26,29 @@ def test_song(self): def test_title(self): msg = "The returned song title does not match the title of the requested song." - self.assertEqual(clean_str(self.song.title), - clean_str(self.song_title), msg) + self.assertEqual(clean_str(self.song.title), clean_str(self.song_title), msg) def test_artist(self): # The returned artist name does not match the artist of the requested song. self.assertEqual(self.song.artist, self.artist_name) def test_lyrics_raw(self): - lyrics = '[Verse 1]' + lyrics = "[Verse 1]" self.assertTrue(self.song.lyrics.startswith(lyrics)) def test_lyrics_no_section_headers(self): - lyrics = 'Begin again\nThis time you should take a bow at the' + lyrics = "Begin again\nThis time you should take a bow at the" self.assertTrue(self.song_trimmed.lyrics.startswith(lyrics)) def test_result_is_lyrics(self): self.assertTrue(genius._result_is_lyrics(self.song.to_dict())) def test_saving_json_file(self): - print('\n') - extension = 'json' + print("\n") + extension = "json" msg = "Could not save {} file.".format(extension) - expected_filename = 'lyrics_save_test_file.' + extension - filename = expected_filename.split('.')[0] + expected_filename = "lyrics_save_test_file." + extension + filename = expected_filename.split(".")[0] # Remove the test file if it already exists if os.path.isfile(expected_filename): @@ -62,34 +61,33 @@ def test_saving_json_file(self): # Test overwriting json file (now that file is written) try: self.song.save_lyrics( - filename=expected_filename, extension=extension, overwrite=True) + filename=expected_filename, extension=extension, overwrite=True + ) os.remove(expected_filename) except Exception: self.fail("Failed {} overwrite test".format(extension)) os.remove(expected_filename) def test_saving_txt_file(self): - print('\n') - extension = 'txt' + print("\n") + extension = "txt" msg = "Could not save {} file.".format(extension) - expected_filename = 'lyrics_save_test_file.' + extension - filename = expected_filename.split('.')[0] + expected_filename = "lyrics_save_test_file." + extension + filename = expected_filename.split(".")[0] # Remove the test file if it already exists if os.path.isfile(expected_filename): os.remove(expected_filename) # Test saving txt file - self.song.save_lyrics(filename=filename, - extension=extension, - overwrite=True) + self.song.save_lyrics(filename=filename, extension=extension, overwrite=True) self.assertTrue(os.path.isfile(expected_filename), msg) # Test overwriting txt file (now that file is written) try: - self.song.save_lyrics(filename=filename, - extension=extension, - overwrite=True) + self.song.save_lyrics( + filename=filename, extension=extension, overwrite=True + ) except Exception: self.fail("Failed {} overwrite test".format(extension)) os.remove(expected_filename) diff --git a/tests/test_utils.py b/tests/test_utils.py index e666143d..eb89e69d 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -3,10 +3,10 @@ from lyricsgenius.utils import ( parse_redirected_url, sanitize_filename, - auth_from_environment + auth_from_environment, ) -from . import genius +from tests import genius class TestUtils(unittest.TestCase): @@ -16,21 +16,21 @@ def setUpClass(cls): print("\n---------------------\nSetting up utils tests...\n") def test_sanitize_filename(self): - raw = 'B@ad File#_name' - cleaned = 'Bad File_name' + raw = "B@ad File#_name" + cleaned = "Bad File_name" r = sanitize_filename(raw) self.assertEqual(r, cleaned) def test_parse_redirected_url(self): - redirected = 'https://example.com/callback?code=test' - flow = 'code' - code = 'test' + redirected = "https://example.com/callback?code=test" + flow = "code" + code = "test" r = parse_redirected_url(redirected, flow) self.assertEqual(r, code) - redirected = 'https://example.com/callback#access_token=test' - flow = 'token' - code = 'test' + redirected = "https://example.com/callback#access_token=test" + flow = "token" + code = "test" r = parse_redirected_url(redirected, flow) self.assertEqual(r, code)