From d9a7ab44efd986c6d594f08265ea6c33f0f26c26 Mon Sep 17 00:00:00 2001 From: auouymous Date: Tue, 24 Oct 2023 04:25:47 -0600 Subject: [PATCH 1/5] Add Python 3.11 and 3.12 to tests. --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 085bea4..194a005 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ jobs: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name strategy: matrix: - python-version: ['2.7', '3.6', '3.8', '3.9', '3.10'] + python-version: ['2.7', '3.6', '3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v3 From 54be8541477c7bfd6ccfc55f1e59cbe6eb3b3b6f Mon Sep 17 00:00:00 2001 From: auouymous Date: Tue, 24 Oct 2023 04:27:01 -0600 Subject: [PATCH 2/5] Switch from distutils to setuptools. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 64e6ebc..8c18573 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ # Generic setup script for single-package Python projects # by Thomas Perl -from distutils.core import setup +from setuptools import setup import re import os From 9aa468709c6db6cfd0ca6fed4c8831996150f0c0 Mon Sep 17 00:00:00 2001 From: auouymous Date: Fri, 3 Nov 2023 03:20:33 -0600 Subject: [PATCH 3/5] Remove unsupported Python 2.7 and 3.6 from tests. --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 194a005..d8e1ad1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ jobs: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name strategy: matrix: - python-version: ['2.7', '3.6', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v3 From c6b978c2768f86004fcf18029072f2b4ac52c9f0 Mon Sep 17 00:00:00 2001 From: auouymous Date: Tue, 24 Oct 2023 04:50:16 -0600 Subject: [PATCH 4/5] Replace assertEquals with assertEqual. --- mygpoclient/api_test.py | 142 ++++++++++++++++++------------------ mygpoclient/http_test.py | 12 +-- mygpoclient/json_test.py | 6 +- mygpoclient/locator_test.py | 10 +-- mygpoclient/public_test.py | 24 +++--- mygpoclient/simple_test.py | 12 +-- 6 files changed, 103 insertions(+), 103 deletions(-) diff --git a/mygpoclient/api_test.py b/mygpoclient/api_test.py index 738c719..882b908 100644 --- a/mygpoclient/api_test.py +++ b/mygpoclient/api_test.py @@ -48,9 +48,9 @@ class Test_SubscriptionChanges(unittest.TestCase): def test_initSetsCorrectAttributes(self): changes = api.SubscriptionChanges(self.ADD, self.REMOVE, self.SINCE) - self.assertEquals(changes.add, self.ADD) - self.assertEquals(changes.remove, self.REMOVE) - self.assertEquals(changes.since, self.SINCE) + self.assertEqual(changes.add, self.ADD) + self.assertEqual(changes.remove, self.REMOVE) + self.assertEqual(changes.since, self.SINCE) class Test_EpisodeActionChanges(unittest.TestCase): @@ -63,8 +63,8 @@ class Test_EpisodeActionChanges(unittest.TestCase): def test_initSetsCorrectAttributes(self): changes = api.EpisodeActionChanges(self.ACTIONS, self.SINCE) - self.assertEquals(changes.actions, self.ACTIONS) - self.assertEquals(changes.since, self.SINCE) + self.assertEqual(changes.actions, self.ACTIONS) + self.assertEqual(changes.since, self.SINCE) class Test_PodcastDevice(unittest.TestCase): @@ -72,10 +72,10 @@ class Test_PodcastDevice(unittest.TestCase): def test_initSetsCorrectAttributes(self): device = api.PodcastDevice(DEVICE_ID_1, self.CAPTION, 'mobile', 42) - self.assertEquals(device.device_id, DEVICE_ID_1) - self.assertEquals(device.caption, self.CAPTION) - self.assertEquals(device.type, 'mobile') - self.assertEquals(device.subscriptions, 42) + self.assertEqual(device.device_id, DEVICE_ID_1) + self.assertEqual(device.caption, self.CAPTION) + self.assertEqual(device.type, 'mobile') + self.assertEqual(device.subscriptions, 42) def test_invalidDeviceType_raisesValueError(self): self.assertRaises(ValueError, @@ -98,14 +98,14 @@ def test_initSetsCorrectAttributes(self): action = api.EpisodeAction(FEED_URL_1, EPISODE_URL_1, 'play', DEVICE_ID_1, self.XML_TIMESTAMP, self.VALID_STARTED, self.VALID_POSITION, self.VALID_TOTAL) - self.assertEquals(action.podcast, FEED_URL_1) - self.assertEquals(action.episode, EPISODE_URL_1) - self.assertEquals(action.action, 'play') - self.assertEquals(action.device, DEVICE_ID_1) - self.assertEquals(action.timestamp, self.XML_TIMESTAMP) - self.assertEquals(action.started, self.VALID_STARTED) - self.assertEquals(action.position, self.VALID_POSITION) - self.assertEquals(action.total, self.VALID_TOTAL) + self.assertEqual(action.podcast, FEED_URL_1) + self.assertEqual(action.episode, EPISODE_URL_1) + self.assertEqual(action.action, 'play') + self.assertEqual(action.device, DEVICE_ID_1) + self.assertEqual(action.timestamp, self.XML_TIMESTAMP) + self.assertEqual(action.started, self.VALID_STARTED) + self.assertEqual(action.position, self.VALID_POSITION) + self.assertEqual(action.total, self.VALID_TOTAL) def test_invalidAction_raisesValueError(self): self.assertRaises(ValueError, @@ -155,20 +155,20 @@ def test_invalidTotalFormat_raisesValueError(self): def test_toDictionary_containsMandatoryAttributes(self): action = api.EpisodeAction(FEED_URL_1, EPISODE_URL_1, 'play') dictionary = action.to_dictionary() - self.assertEquals(len(list(dictionary.keys())), 3) + self.assertEqual(len(list(dictionary.keys())), 3) self.assert_('podcast' in dictionary) self.assert_('episode' in dictionary) self.assert_('action' in dictionary) - self.assertEquals(dictionary['podcast'], FEED_URL_1) - self.assertEquals(dictionary['episode'], EPISODE_URL_1) - self.assertEquals(dictionary['action'], 'play') + self.assertEqual(dictionary['podcast'], FEED_URL_1) + self.assertEqual(dictionary['episode'], EPISODE_URL_1) + self.assertEqual(dictionary['action'], 'play') def test_toDictionary_containsAllAttributes(self): action = api.EpisodeAction(FEED_URL_3, EPISODE_URL_4, 'play', DEVICE_ID_1, self.XML_TIMESTAMP, self.VALID_STARTED, self.VALID_POSITION, self.VALID_TOTAL) dictionary = action.to_dictionary() - self.assertEquals(len(list(dictionary.keys())), 8) + self.assertEqual(len(list(dictionary.keys())), 8) self.assert_('podcast' in dictionary) self.assert_('episode' in dictionary) self.assert_('action' in dictionary) @@ -177,14 +177,14 @@ def test_toDictionary_containsAllAttributes(self): self.assert_('started' in dictionary) self.assert_('position' in dictionary) self.assert_('total' in dictionary) - self.assertEquals(dictionary['podcast'], FEED_URL_3) - self.assertEquals(dictionary['episode'], EPISODE_URL_4) - self.assertEquals(dictionary['action'], 'play') - self.assertEquals(dictionary['device'], DEVICE_ID_1) - self.assertEquals(dictionary['timestamp'], self.XML_TIMESTAMP) - self.assertEquals(dictionary['started'], self.VALID_STARTED) - self.assertEquals(dictionary['position'], self.VALID_POSITION) - self.assertEquals(dictionary['total'], self.VALID_TOTAL) + self.assertEqual(dictionary['podcast'], FEED_URL_3) + self.assertEqual(dictionary['episode'], EPISODE_URL_4) + self.assertEqual(dictionary['action'], 'play') + self.assertEqual(dictionary['device'], DEVICE_ID_1) + self.assertEqual(dictionary['timestamp'], self.XML_TIMESTAMP) + self.assertEqual(dictionary['started'], self.VALID_STARTED) + self.assertEqual(dictionary['position'], self.VALID_POSITION) + self.assertEqual(dictionary['total'], self.VALID_TOTAL) class Test_MygPodderClient(unittest.TestCase): @@ -223,13 +223,13 @@ def set_http_response_value(self, value): self.fake_client.response_value = value def assert_http_request_count(self, count): - self.assertEquals(len(self.fake_client.requests), count) + self.assertEqual(len(self.fake_client.requests), count) def has_put_json_data(self, data, required_method='PUT'): """Returns True if the FakeJsonClient has received the given data""" for method, uri, sent in self.fake_client.requests: if method == required_method: - self.assertEquals(sent, data) + self.assertEqual(sent, data) return True return False @@ -241,13 +241,13 @@ def has_posted_json_data(self, data): def test_getSubscriptions_withPodcastDevice(self): self.set_http_response_value(b'[]') device = api.PodcastDevice('manatee', 'My Device', 'mobile', 20) - self.assertEquals(self.client.get_subscriptions(device), []) + self.assertEqual(self.client.get_subscriptions(device), []) self.assert_http_request_count(1) def test_putSubscriptions_withPodcastDevice(self): self.set_http_response_value(b'') device = api.PodcastDevice('manatee', 'My Device', 'mobile', 20) - self.assertEquals( + self.assertEqual( self.client.put_subscriptions( device, self.ADD), True) self.assert_http_request_count(1) @@ -336,8 +336,8 @@ def test_updateSubscriptions_returnsUpdateResult(self): # result is a UpdateResult object self.assert_(hasattr(result, 'since')) self.assert_(hasattr(result, 'update_urls')) - self.assertEquals(result.since, self.SINCE) - self.assertEquals(result.update_urls, update_urls_expected) + self.assertEqual(result.since, self.SINCE) + self.assertEqual(result.update_urls, update_urls_expected) self.assert_http_request_count(1) self.assert_(self.has_posted_json_data(self.ADD_REMOVE_AS_JSON_UPLOAD)) @@ -442,9 +442,9 @@ def test_pullSubscriptions_returnsChangesListAndTimestamp(self): "timestamp": 1262103016} """) changes = self.client.pull_subscriptions(DEVICE_ID_2) - self.assertEquals(changes.add, [FEED_URL_1, FEED_URL_2]) - self.assertEquals(changes.remove, [FEED_URL_3, FEED_URL_4]) - self.assertEquals(changes.since, self.SINCE) + self.assertEqual(changes.add, [FEED_URL_1, FEED_URL_2]) + self.assertEqual(changes.remove, [FEED_URL_3, FEED_URL_4]) + self.assertEqual(changes.since, self.SINCE) self.assert_http_request_count(1) def test_uploadEpisodeActions_raisesInvalidResponse_onEmptyResponse(self): @@ -471,7 +471,7 @@ def test_uploadEpisodeActions_returnsTimestamp(self): {"timestamp": 1262103016} """) result = self.client.upload_episode_actions(self.ACTIONS) - self.assertEquals(result, self.SINCE) + self.assertEqual(result, self.SINCE) self.assert_http_request_count(1) self.assert_(self.has_posted_json_data(self.ACTIONS_AS_JSON_UPLOAD)) @@ -535,21 +535,21 @@ def test_downloadEpisodeActions_returnsActionList(self): ], "timestamp": 1262103016} """) changes = self.client.download_episode_actions() - self.assertEquals(len(changes.actions), 2) + self.assertEqual(len(changes.actions), 2) action1, action2 = changes.actions - self.assertEquals(action1.podcast, 'a') - self.assertEquals(action1.episode, 'b') - self.assertEquals(action1.action, 'download') - self.assertEquals(action2.podcast, 'x') - self.assertEquals(action2.episode, 'y') - self.assertEquals(action2.action, 'play') - self.assertEquals(changes.since, self.SINCE) + self.assertEqual(action1.podcast, 'a') + self.assertEqual(action1.episode, 'b') + self.assertEqual(action1.action, 'download') + self.assertEqual(action2.podcast, 'x') + self.assertEqual(action2.episode, 'y') + self.assertEqual(action2.action, 'play') + self.assertEqual(changes.since, self.SINCE) self.assert_http_request_count(1) def test_updateDeviceSettings_withNothing(self): self.set_http_response_value(b'') result = self.client.update_device_settings(DEVICE_ID_1) - self.assertEquals(result, True) + self.assertEqual(result, True) self.assert_http_request_count(1) self.assert_(self.has_posted_json_data({})) @@ -557,7 +557,7 @@ def test_updateDeviceSettings_withCaption(self): self.set_http_response_value(b'') result = self.client.update_device_settings(DEVICE_ID_1, caption='Poodonkis') - self.assertEquals(result, True) + self.assertEqual(result, True) self.assert_http_request_count(1) self.assert_(self.has_posted_json_data({'caption': 'Poodonkis'})) @@ -565,7 +565,7 @@ def test_updateDeviceSettings_withType(self): self.set_http_response_value(b'') result = self.client.update_device_settings(DEVICE_ID_1, type='desktop') - self.assertEquals(result, True) + self.assertEqual(result, True) self.assert_http_request_count(1) self.assert_(self.has_posted_json_data({'type': 'desktop'})) @@ -573,7 +573,7 @@ def test_updateDeviceSettings_withCaptionAndType(self): self.set_http_response_value(b'') result = self.client.update_device_settings(DEVICE_ID_1, 'My Unit Testing Device', 'desktop') - self.assertEquals(result, True) + self.assertEqual(result, True) self.assert_http_request_count(1) self.assert_(self.has_posted_json_data({ 'caption': 'My Unit Testing Device', @@ -610,16 +610,16 @@ def test_getDevices_returnsDeviceList(self): ] """) devices = self.client.get_devices() - self.assertEquals(len(devices), 2) + self.assertEqual(len(devices), 2) device1, device2 = devices - self.assertEquals(device1.device_id, DEVICE_ID_1) - self.assertEquals(device1.caption, 'Phone') - self.assertEquals(device1.type, 'mobile') - self.assertEquals(device1.subscriptions, 42) - self.assertEquals(device2.device_id, DEVICE_ID_2) - self.assertEquals(device2.caption, 'The Lappy') - self.assertEquals(device2.type, 'laptop') - self.assertEquals(device2.subscriptions, 4711) + self.assertEqual(device1.device_id, DEVICE_ID_1) + self.assertEqual(device1.caption, 'Phone') + self.assertEqual(device1.type, 'mobile') + self.assertEqual(device1.subscriptions, 42) + self.assertEqual(device2.device_id, DEVICE_ID_2) + self.assertEqual(device2.caption, 'The Lappy') + self.assertEqual(device2.type, 'laptop') + self.assertEqual(device2.subscriptions, 4711) self.assert_http_request_count(1) def test_getFavoriteEpisodes_returnsEpisodeList(self): @@ -644,24 +644,24 @@ def test_getFavoriteEpisodes_returnsEpisodeList(self): ] """) favorites = self.client.get_favorite_episodes() - self.assertEquals(len(favorites), 2) + self.assertEqual(len(favorites), 2) episode1, episode2 = favorites - self.assertEquals(episode1.title, 'TWiT 245: No Hitler For You') - self.assertEquals( + self.assertEqual(episode1.title, 'TWiT 245: No Hitler For You') + self.assertEqual( episode1.url, 'http://www.podtrac.com/pts/redirect.mp3/aolradio.podcast.aol.com/twit/twit0245.mp3') - self.assertEquals( + self.assertEqual( episode1.podcast_title, 'this WEEK in TECH - MP3 Edition') - self.assertEquals(episode1.podcast_url, 'http://leo.am/podcasts/twit') - self.assertEquals(episode1.description, '[...]') - self.assertEquals( + self.assertEqual(episode1.podcast_url, 'http://leo.am/podcasts/twit') + self.assertEqual(episode1.description, '[...]') + self.assertEqual( episode1.website, 'http://www.podtrac.com/pts/redirect.mp3/aolradio.podcast.aol.com/twit/twit0245.mp3') - self.assertEquals(episode1.released, '2010-12-25T00:30:00') - self.assertEquals( + self.assertEqual(episode1.released, '2010-12-25T00:30:00') + self.assertEqual( episode1.mygpo_link, 'http://gpodder.net/episode/1046492') - self.assertEquals( + self.assertEqual( episode2.website, 'http://feedproxy.google.com/~r/coverville/~3/5UK8-PZmmMQ/') diff --git a/mygpoclient/http_test.py b/mygpoclient/http_test.py index 0bb9491..478ba2b 100644 --- a/mygpoclient/http_test.py +++ b/mygpoclient/http_test.py @@ -171,12 +171,12 @@ def test_BadRequest(self): def test_GET(self): client = HttpClient() path = self.URI_BASE + '/noauth' - self.assertEquals(client.GET(path), self.RESPONSE) + self.assertEqual(client.GET(path), self.RESPONSE) def test_authenticated_GET(self): client = HttpClient(self.USERNAME, self.PASSWORD) path = self.URI_BASE + '/auth' - self.assertEquals(client.GET(path), self.RESPONSE) + self.assertEqual(client.GET(path), self.RESPONSE) def test_unauthenticated_GET(self): client = HttpClient() @@ -186,7 +186,7 @@ def test_unauthenticated_GET(self): def test_POST(self): client = HttpClient() path = self.URI_BASE + '/noauth' - self.assertEquals( + self.assertEqual( client.POST( path, self.DUMMYDATA), codecs.encode( self.DUMMYDATA.decode('utf-8'), 'rot-13').encode('utf-8')) @@ -194,7 +194,7 @@ def test_POST(self): def test_authenticated_POST(self): client = HttpClient(self.USERNAME, self.PASSWORD) path = self.URI_BASE + '/auth' - self.assertEquals( + self.assertEqual( client.POST( path, self.DUMMYDATA), codecs.encode( self.DUMMYDATA.decode('utf-8'), 'rot-13').encode('utf-8')) @@ -207,14 +207,14 @@ def test_unauthenticated_POST(self): def test_PUT(self): client = HttpClient() path = self.URI_BASE + '/noauth' - self.assertEquals(client.PUT(path, self.DUMMYDATA), b'PUT OK') + self.assertEqual(client.PUT(path, self.DUMMYDATA), b'PUT OK') def test_GET_after_PUT(self): client = HttpClient() for i in range(10): path = self.URI_BASE + '/file.%(i)d.txt' % locals() client.PUT(path, self.RESPONSE + str(i).encode('utf-8')) - self.assertEquals( + self.assertEqual( client.GET(path), self.RESPONSE + str(i).encode('utf-8')) diff --git a/mygpoclient/json_test.py b/mygpoclient/json_test.py index 8517b56..a8a370a 100644 --- a/mygpoclient/json_test.py +++ b/mygpoclient/json_test.py @@ -61,17 +61,17 @@ def test_parseResponse_worksWithDictionary(self): client = json.JsonClient(self.USERNAME, self.PASSWORD) self.mock_setHttpResponse(b'{"a": "B", "c": "D"}') items = list(sorted(client.GET(self.URI_BASE + '/').items())) - self.assertEquals(items, [('a', 'B'), ('c', 'D')]) + self.assertEqual(items, [('a', 'B'), ('c', 'D')]) def test_parseResponse_worksWithIntegerList(self): client = json.JsonClient(self.USERNAME, self.PASSWORD) self.mock_setHttpResponse(b'[1,2,3,6,7]') - self.assertEquals(client.GET(self.URI_BASE + '/'), [1, 2, 3, 6, 7]) + self.assertEqual(client.GET(self.URI_BASE + '/'), [1, 2, 3, 6, 7]) def test_parseResponse_emptyString_returnsNone(self): client = json.JsonClient(self.USERNAME, self.PASSWORD) self.mock_setHttpResponse(b'') - self.assertEquals(client.GET(self.URI_BASE + '/'), None) + self.assertEqual(client.GET(self.URI_BASE + '/'), None) def test_invalidContent_raisesJsonException(self): client = json.JsonClient(self.USERNAME, self.PASSWORD) diff --git a/mygpoclient/locator_test.py b/mygpoclient/locator_test.py index f9e30fd..57eca59 100644 --- a/mygpoclient/locator_test.py +++ b/mygpoclient/locator_test.py @@ -81,28 +81,28 @@ def test_unsupported_settings_uri_exception2(self): def test_subscriptions_uri_no_device(self): """Test that no device returns user subscriptions""" - self.assertEquals(self.locator.subscriptions_uri(), + self.assertEqual(self.locator.subscriptions_uri(), 'http://gpodder.net/subscriptions/jane.opml') def test_root_uri(self): """Test that root_uri trivially works""" - self.assertEquals(self.locator.root_uri(), + self.assertEqual(self.locator.root_uri(), 'http://gpodder.net') def test_create_with_url(self): """Test locator creation with a root URL instead of host""" loc = locator.Locator('hello', 'https://gpo.self.hosted/my') - self.assertEquals(loc.toplist_uri(), + self.assertEqual(loc.toplist_uri(), 'https://gpo.self.hosted/my/toplist/50.opml') def test_create_with_url_slash(self): """Test locator creation with a root URL ending with a slash""" loc = locator.Locator('hello', 'https://gpo.self.hosted/my/') - self.assertEquals(loc.toplist_uri(), + self.assertEqual(loc.toplist_uri(), 'https://gpo.self.hosted/my/toplist/50.opml') def test_create_with_host(self): """Test locator creation with a host""" loc = locator.Locator('hello', 'gpo.self.hosted') - self.assertEquals(loc.toplist_uri(), + self.assertEqual(loc.toplist_uri(), 'http://gpo.self.hosted/toplist/50.opml') diff --git a/mygpoclient/public_test.py b/mygpoclient/public_test.py index 602c834..8287204 100644 --- a/mygpoclient/public_test.py +++ b/mygpoclient/public_test.py @@ -172,38 +172,38 @@ def setUp(self): def test_getToplist(self): self.fake_client.response_value = self.TOPLIST_JSON result = self.client.get_toplist() - self.assertEquals(result, self.TOPLIST) - self.assertEquals(len(self.fake_client.requests), 1) + self.assertEqual(result, self.TOPLIST) + self.assertEqual(len(self.fake_client.requests), 1) def test_searchPodcasts(self): self.fake_client.response_value = self.SEARCHRESULT_JSON result = self.client.search_podcasts('wicked') - self.assertEquals(result, self.SEARCHRESULT) - self.assertEquals(len(self.fake_client.requests), 1) + self.assertEqual(result, self.SEARCHRESULT) + self.assertEqual(len(self.fake_client.requests), 1) def test_getPodcastsOfATag(self): self.fake_client.response_value = self.SEARCHRESULT_JSON result = self.client.get_podcasts_of_a_tag('wicked') - self.assertEquals(result, self.SEARCHRESULT) - self.assertEquals(len(self.fake_client.requests), 1) + self.assertEqual(result, self.SEARCHRESULT) + self.assertEqual(len(self.fake_client.requests), 1) def test_getTopTags(self): self.fake_client.response_value = self.TOPTAGS_JSON result = self.client.get_toptags() - self.assertEquals(result, self.TOPTAGS) - self.assertEquals(len(self.fake_client.requests), 1) + self.assertEqual(result, self.TOPTAGS) + self.assertEqual(len(self.fake_client.requests), 1) def test_getPodcastData(self): self.fake_client.response_value = self.PODCAST_JSON result = self.client.get_podcast_data( 'http://feeds.feedburner.com/linuxoutlaws') - self.assertEquals(result, self.PODCAST) - self.assertEquals(len(self.fake_client.requests), 1) + self.assertEqual(result, self.PODCAST) + self.assertEqual(len(self.fake_client.requests), 1) def test_getEpisodeData(self): self.fake_client.response_value = self.EPISODE_JSON result = self.client.get_episode_data( 'http://leo.am/podcasts/twit', 'http://www.podtrac.com/pts/redirect.mp3/aolradio.podcast.aol.com/twit/twit0245.mp3') - self.assertEquals(result, self.EPISODE) - self.assertEquals(len(self.fake_client.requests), 1) + self.assertEqual(result, self.EPISODE) + self.assertEqual(len(self.fake_client.requests), 1) diff --git a/mygpoclient/simple_test.py b/mygpoclient/simple_test.py index 6b97361..d93235f 100644 --- a/mygpoclient/simple_test.py +++ b/mygpoclient/simple_test.py @@ -87,20 +87,20 @@ def test_putSubscriptions(self): self.fake_client.response_value = b'' result = self.client.put_subscriptions( self.DEVICE_NAME, self.SUBSCRIPTIONS) - self.assertEquals(result, True) - self.assertEquals(len(self.fake_client.requests), 1) + self.assertEqual(result, True) + self.assertEqual(len(self.fake_client.requests), 1) def test_getSubscriptions(self): self.fake_client.response_value = self.SUBSCRIPTIONS_JSON subscriptions = self.client.get_subscriptions(self.DEVICE_NAME) - self.assertEquals(subscriptions, self.SUBSCRIPTIONS) - self.assertEquals(len(self.fake_client.requests), 1) + self.assertEqual(subscriptions, self.SUBSCRIPTIONS) + self.assertEqual(len(self.fake_client.requests), 1) def test_getSuggestions(self): self.fake_client.response_value = self.SUGGESTIONS_JSON suggestions = self.client.get_suggestions(50) - self.assertEquals(suggestions, self.SUGGESTIONS) - self.assertEquals(len(self.fake_client.requests), 1) + self.assertEqual(suggestions, self.SUGGESTIONS) + self.assertEqual(len(self.fake_client.requests), 1) class Test_MissingCredentials(unittest.TestCase): From 65af6f00bdd817e7cb41b93e99d3c072f0a9aee1 Mon Sep 17 00:00:00 2001 From: auouymous Date: Tue, 24 Oct 2023 05:05:07 -0600 Subject: [PATCH 5/5] Replace assert_ with assertIn or assertTrue. --- mygpoclient/api_test.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/mygpoclient/api_test.py b/mygpoclient/api_test.py index 882b908..854e0ae 100644 --- a/mygpoclient/api_test.py +++ b/mygpoclient/api_test.py @@ -156,9 +156,9 @@ def test_toDictionary_containsMandatoryAttributes(self): action = api.EpisodeAction(FEED_URL_1, EPISODE_URL_1, 'play') dictionary = action.to_dictionary() self.assertEqual(len(list(dictionary.keys())), 3) - self.assert_('podcast' in dictionary) - self.assert_('episode' in dictionary) - self.assert_('action' in dictionary) + self.assertIn('podcast', dictionary) + self.assertIn('episode', dictionary) + self.assertIn('action', dictionary) self.assertEqual(dictionary['podcast'], FEED_URL_1) self.assertEqual(dictionary['episode'], EPISODE_URL_1) self.assertEqual(dictionary['action'], 'play') @@ -169,14 +169,14 @@ def test_toDictionary_containsAllAttributes(self): self.VALID_POSITION, self.VALID_TOTAL) dictionary = action.to_dictionary() self.assertEqual(len(list(dictionary.keys())), 8) - self.assert_('podcast' in dictionary) - self.assert_('episode' in dictionary) - self.assert_('action' in dictionary) - self.assert_('device' in dictionary) - self.assert_('timestamp' in dictionary) - self.assert_('started' in dictionary) - self.assert_('position' in dictionary) - self.assert_('total' in dictionary) + self.assertIn('podcast', dictionary) + self.assertIn('episode', dictionary) + self.assertIn('action', dictionary) + self.assertIn('device', dictionary) + self.assertIn('timestamp', dictionary) + self.assertIn('started', dictionary) + self.assertIn('position', dictionary) + self.assertIn('total', dictionary) self.assertEqual(dictionary['podcast'], FEED_URL_3) self.assertEqual(dictionary['episode'], EPISODE_URL_4) self.assertEqual(dictionary['action'], 'play') @@ -251,7 +251,7 @@ def test_putSubscriptions_withPodcastDevice(self): self.client.put_subscriptions( device, self.ADD), True) self.assert_http_request_count(1) - self.assert_(self.has_put_json_data(self.ADD)) + self.assertTrue(self.has_put_json_data(self.ADD)) def test_updateSubscriptions_raisesValueError_onInvalidAddList(self): self.assertRaises(ValueError, @@ -334,12 +334,12 @@ def test_updateSubscriptions_returnsUpdateResult(self): result = self.client.update_subscriptions(DEVICE_ID_1, self.ADD, self.REMOVE) # result is a UpdateResult object - self.assert_(hasattr(result, 'since')) - self.assert_(hasattr(result, 'update_urls')) + self.assertTrue(hasattr(result, 'since')) + self.assertTrue(hasattr(result, 'update_urls')) self.assertEqual(result.since, self.SINCE) self.assertEqual(result.update_urls, update_urls_expected) self.assert_http_request_count(1) - self.assert_(self.has_posted_json_data(self.ADD_REMOVE_AS_JSON_UPLOAD)) + self.assertTrue(self.has_posted_json_data(self.ADD_REMOVE_AS_JSON_UPLOAD)) def test_pullSubscriptions_raisesInvalidResponse_onEmptyResponse(self): self.set_http_response_value(b'') @@ -473,7 +473,7 @@ def test_uploadEpisodeActions_returnsTimestamp(self): result = self.client.upload_episode_actions(self.ACTIONS) self.assertEqual(result, self.SINCE) self.assert_http_request_count(1) - self.assert_(self.has_posted_json_data(self.ACTIONS_AS_JSON_UPLOAD)) + self.assertTrue(self.has_posted_json_data(self.ACTIONS_AS_JSON_UPLOAD)) def test_downloadEpisodeActions_raisesInvalidResponse_onEmptyResponse( self): @@ -551,7 +551,7 @@ def test_updateDeviceSettings_withNothing(self): result = self.client.update_device_settings(DEVICE_ID_1) self.assertEqual(result, True) self.assert_http_request_count(1) - self.assert_(self.has_posted_json_data({})) + self.assertTrue(self.has_posted_json_data({})) def test_updateDeviceSettings_withCaption(self): self.set_http_response_value(b'') @@ -559,7 +559,7 @@ def test_updateDeviceSettings_withCaption(self): caption='Poodonkis') self.assertEqual(result, True) self.assert_http_request_count(1) - self.assert_(self.has_posted_json_data({'caption': 'Poodonkis'})) + self.assertTrue(self.has_posted_json_data({'caption': 'Poodonkis'})) def test_updateDeviceSettings_withType(self): self.set_http_response_value(b'') @@ -567,7 +567,7 @@ def test_updateDeviceSettings_withType(self): type='desktop') self.assertEqual(result, True) self.assert_http_request_count(1) - self.assert_(self.has_posted_json_data({'type': 'desktop'})) + self.assertTrue(self.has_posted_json_data({'type': 'desktop'})) def test_updateDeviceSettings_withCaptionAndType(self): self.set_http_response_value(b'') @@ -575,7 +575,7 @@ def test_updateDeviceSettings_withCaptionAndType(self): 'My Unit Testing Device', 'desktop') self.assertEqual(result, True) self.assert_http_request_count(1) - self.assert_(self.has_posted_json_data({ + self.assertTrue(self.has_posted_json_data({ 'caption': 'My Unit Testing Device', 'type': 'desktop'}))