diff --git a/test/plugins/test_art.py b/test/plugins/test_art.py index 1d8ca7698..fc85cc8e9 100644 --- a/test/plugins/test_art.py +++ b/test/plugins/test_art.py @@ -214,7 +214,7 @@ class FetchImageTest(FetchImageTestCase): def test_jpeg_type_returns_path(self): self.mock_response(self.URL, "image/jpeg") self.source.fetch_image(self.candidate, self.settings) - self.assertIsNotNone(self.candidate.path) + assert self.candidate.path is not None def test_extension_set_by_content_type(self): self.mock_response(self.URL, "image/png") @@ -294,7 +294,7 @@ class CombinedTest(FetchImageTestCase, CAAHelper): self.mock_response(self.AMAZON_URL) album = _common.Bag(asin=self.ASIN) candidate = self.plugin.art_for_album(album, None) - self.assertIsNotNone(candidate) + assert candidate is not None def test_main_interface_returns_none_for_missing_asin_and_path(self): album = _common.Bag() @@ -306,14 +306,14 @@ class CombinedTest(FetchImageTestCase, CAAHelper): self.mock_response(self.AMAZON_URL) album = _common.Bag(asin=self.ASIN) candidate = self.plugin.art_for_album(album, [self.dpath]) - self.assertIsNotNone(candidate) + assert candidate is not None self.assertEqual(candidate.path, os.path.join(self.dpath, b"art.jpg")) def test_main_interface_falls_back_to_amazon(self): self.mock_response(self.AMAZON_URL) album = _common.Bag(asin=self.ASIN) candidate = self.plugin.art_for_album(album, [self.dpath]) - self.assertIsNotNone(candidate) + assert candidate is not None assert not candidate.path.startswith(self.dpath) def test_main_interface_tries_amazon_before_aao(self): @@ -346,7 +346,7 @@ class CombinedTest(FetchImageTestCase, CAAHelper): asin=self.ASIN, ) candidate = self.plugin.art_for_album(album, None) - self.assertIsNotNone(candidate) + assert candidate is not None self.assertEqual(len(responses.calls), 3) self.assertEqual(responses.calls[0].request.url, self.RELEASE_URL) @@ -361,7 +361,7 @@ class CombinedTest(FetchImageTestCase, CAAHelper): candidate = self.plugin.art_for_album( album, [self.dpath], local_only=True ) - self.assertIsNotNone(candidate) + assert candidate is not None self.assertEqual(candidate.path, os.path.join(self.dpath, b"art.jpg")) self.assertEqual(len(responses.calls), 0) diff --git a/test/plugins/test_convert.py b/test/plugins/test_convert.py index 10a8b8046..e9f8348db 100644 --- a/test/plugins/test_convert.py +++ b/test/plugins/test_convert.py @@ -121,7 +121,7 @@ class ImportConvertTest(AsIsImporterMixin, ImportHelper, ConvertTestCase): self.run_asis_importer() item = self.lib.items().get() - self.assertIsNotNone(item) + assert item is not None self.assertIsFile(item.path) def test_delete_originals(self): diff --git a/test/plugins/test_export.py b/test/plugins/test_export.py index f9f28f8de..374c2529d 100644 --- a/test/plugins/test_export.py +++ b/test/plugins/test_export.py @@ -70,7 +70,7 @@ class ExportPluginTest(PluginTestCase): head = re.split(",", csv_list[0]) vals = re.split(",|\r", csv_list[1]) for index, column in enumerate(head): - self.assertIsNotNone(self.test_values.get(column, None)) + assert self.test_values.get(column, None) is not None self.assertEqual(vals[index], self.test_values[column]) def test_xml_output(self): diff --git a/test/plugins/test_lyrics.py b/test/plugins/test_lyrics.py index f6fbc44a2..d756c1846 100644 --- a/test/plugins/test_lyrics.py +++ b/test/plugins/test_lyrics.py @@ -488,7 +488,7 @@ class GeniusScrapeLyricsFromHtmlTest(GeniusBaseTest): url = "https://genius.com/Ttng-chinchilla-lyrics" mock = MockFetchUrl() lyrics = genius._scrape_lyrics_from_html(mock(url)) - self.assertIsNotNone(lyrics) + assert lyrics is not None self.assertEqual(lyrics.count("\n"), 28) def test_good_lyrics_multiple_divs(self): @@ -496,7 +496,7 @@ class GeniusScrapeLyricsFromHtmlTest(GeniusBaseTest): url = "https://genius.com/2pac-all-eyez-on-me-lyrics" mock = MockFetchUrl() lyrics = genius._scrape_lyrics_from_html(mock(url)) - self.assertIsNotNone(lyrics) + assert lyrics is not None self.assertEqual(lyrics.count("\n"), 133) # TODO: find an example of a lyrics page with multiple divs and test it @@ -540,12 +540,12 @@ class GeniusFetchTest(GeniusBaseTest): ) as mock_json: # genius uses zero-width-spaces (\u200B) for lowercase # artists so we make sure we can match those - self.assertIsNotNone(genius.fetch("blackbear", "Idfc")) + assert genius.fetch("blackbear", "Idfc") is not None mock_fetch_url.assert_called_once_with("blackbear_url") mock_scrape.assert_called_once_with(True) # genius uses the hyphen minus (\u002D) as their dash - self.assertIsNotNone(genius.fetch("El-p", "Idfc")) + assert genius.fetch("El-p", "Idfc") is not None mock_fetch_url.assert_called_with("El-p_url") mock_scrape.assert_called_with(True) @@ -584,8 +584,9 @@ class TekstowoExtractLyricsTest(TekstowoBaseTest): """Ensure we are able to scrape a page with lyrics""" url = "https://www.tekstowo.pl/piosenka,24kgoldn,city_of_angels_1.html" mock = MockFetchUrl() - self.assertIsNotNone( + assert ( tekstowo.extract_lyrics(mock(url), "24kGoldn", "City of Angels") + is not None ) def test_no_lyrics(self): diff --git a/test/plugins/test_replaygain.py b/test/plugins/test_replaygain.py index bd839a4a1..0f770da29 100644 --- a/test/plugins/test_replaygain.py +++ b/test/plugins/test_replaygain.py @@ -146,8 +146,8 @@ class ReplayGainCliTest: self.skipTest("decoder plugins could not be loaded.") for item in self.lib.items(): - self.assertIsNotNone(item.rg_track_peak) - self.assertIsNotNone(item.rg_track_gain) + assert item.rg_track_peak is not None + assert item.rg_track_gain is not None mediafile = MediaFile(item.path) self.assertAlmostEqual( mediafile.rg_track_peak, item.rg_track_peak, places=6 @@ -167,8 +167,8 @@ class ReplayGainCliTest: self.run_command("replaygain") item_rg.load() - self.assertIsNotNone(item_rg.rg_track_gain) - self.assertIsNotNone(item_rg.rg_track_peak) + assert item_rg.rg_track_gain is not None + assert item_rg.rg_track_peak is not None assert item_rg.r128_track_gain is None item_rg.rg_track_gain += 1.0 @@ -179,7 +179,7 @@ class ReplayGainCliTest: if self.has_r128_support: item_r128.load() - self.assertIsNotNone(item_r128.r128_track_gain) + assert item_r128.r128_track_gain is not None assert item_r128.rg_track_gain is None assert item_r128.rg_track_peak is None @@ -225,12 +225,12 @@ class ReplayGainCliTest: item_rg.load() item_r128.load() - self.assertIsNotNone(item_rg.rg_track_gain) - self.assertIsNotNone(item_rg.rg_track_peak) + assert item_rg.rg_track_gain is not None + assert item_rg.rg_track_peak is not None # FIXME: Should the plugin null this field? # assert item_rg.r128_track_gain is None - self.assertIsNotNone(item_r128.r128_track_gain) + assert item_r128.r128_track_gain is not None # FIXME: Should the plugin null these fields? # assert item_r128.rg_track_gain is None # assert item_r128.rg_track_peak is None @@ -277,8 +277,8 @@ class ReplayGainCliTest: assert mediafile.rg_track_gain is None assert mediafile.rg_album_gain is None # writes R128_* tags - self.assertIsNotNone(mediafile.r128_track_gain) - self.assertIsNotNone(mediafile.r128_album_gain) + assert mediafile.r128_track_gain is not None + assert mediafile.r128_album_gain is not None def test_targetlevel_has_effect(self): album = self._add_album(1) @@ -326,8 +326,8 @@ class ReplayGainCliTest: # FIXME: Add fixtures with known track/album gain (within a suitable # tolerance) so that we can actually check per-disc operation here. for item in album.items(): - self.assertIsNotNone(item.rg_track_gain) - self.assertIsNotNone(item.rg_album_gain) + assert item.rg_track_gain is not None + assert item.rg_album_gain is not None @unittest.skipIf(not GST_AVAILABLE, "gstreamer cannot be found") @@ -365,8 +365,8 @@ class ImportTest(AsIsImporterMixin): # FIXME: Add fixtures with known track/album gain (within a # suitable tolerance) so that we can actually check correct # operation here. - self.assertIsNotNone(item.rg_track_gain) - self.assertIsNotNone(item.rg_album_gain) + assert item.rg_track_gain is not None + assert item.rg_album_gain is not None @unittest.skipIf(not GST_AVAILABLE, "gstreamer cannot be found") diff --git a/test/test_importer.py b/test/test_importer.py index 4cd2d0896..166a62768 100644 --- a/test/test_importer.py +++ b/test/test_importer.py @@ -1343,11 +1343,11 @@ class ResumeImportTest(ImportTestCase): self.importer.run() self.assertEqual(len(self.lib.albums()), 1) - self.assertIsNotNone(self.lib.albums("album:'Album 1'").get()) + assert self.lib.albums("album:'Album 1'").get() is not None self.importer.run() self.assertEqual(len(self.lib.albums()), 2) - self.assertIsNotNone(self.lib.albums("album:'Album 2'").get()) + assert self.lib.albums("album:'Album 2'").get() is not None @patch("beets.plugins.send") def test_resume_singleton(self, plugins_send): @@ -1366,11 +1366,11 @@ class ResumeImportTest(ImportTestCase): self.importer.run() self.assertEqual(len(self.lib.items()), 1) - self.assertIsNotNone(self.lib.items("title:'Track 1'").get()) + assert self.lib.items("title:'Track 1'").get() is not None self.importer.run() self.assertEqual(len(self.lib.items()), 2) - self.assertIsNotNone(self.lib.items("title:'Track 1'").get()) + assert self.lib.items("title:'Track 1'").get() is not None class IncrementalImportTest(AsIsImporterMixin, ImportTestCase): diff --git a/test/test_library.py b/test/test_library.py index fb3744658..b4421e89b 100644 --- a/test/test_library.py +++ b/test/test_library.py @@ -963,7 +963,7 @@ class AlbumInfoTest(BeetsTestCase): c = self.lib._connection().cursor() c.execute("select * from albums where album=?", (self.i.album,)) # Cursor should only return one row. - self.assertIsNotNone(c.fetchone()) + assert c.fetchone() is not None assert c.fetchone() is None def test_individual_tracks_have_no_albuminfo(self): @@ -976,7 +976,7 @@ class AlbumInfoTest(BeetsTestCase): def test_get_album_by_id(self): ai = self.lib.get_album(self.i) ai = self.lib.get_album(self.i.id) - self.assertIsNotNone(ai) + assert ai is not None def test_album_items_consistent(self): ai = self.lib.get_album(self.i) diff --git a/test/test_plugins.py b/test/test_plugins.py index d5a542244..02dd910e6 100644 --- a/test/test_plugins.py +++ b/test/test_plugins.py @@ -154,7 +154,7 @@ class ItemTypeConflictTest(PluginLoaderTestCase): self.advent_listener_plugin = AdventListenerPlugin self.register_plugin(EventListenerPlugin) self.register_plugin(AdventListenerPlugin) - self.assertIsNotNone(plugins.types(Item)) + assert plugins.types(Item) is not None class EventsTest(PluginImportTestCase): diff --git a/test/test_ui.py b/test/test_ui.py index 5c03f515e..0b8e107e0 100644 --- a/test/test_ui.py +++ b/test/test_ui.py @@ -675,7 +675,7 @@ class UpdateTest(BeetsTestCase): self._update(move=True) album = self.lib.albums()[0] self.assertNotEqual(artpath, album.artpath) - self.assertIsNotNone(album.artpath) + assert album.artpath is not None def test_selective_modified_album_metadata_moved(self): mf = MediaFile(syspath(self.i.path))