diff options
author | Serene <33189705+Serene-Arc@users.noreply.github.com> | 2024-04-21 09:06:38 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-21 09:06:38 +1000 |
commit | 7543a351ed9938a17dd855213d0264b42f482c4b (patch) | |
tree | cc52b4a85b905c4f55b97d3ed42f25e3fc035650 | |
parent | d5101778206fa4f0ea2b6548d14f93728fb7c9d3 (diff) | |
parent | f46bbbdb6000d20f0db2603de4f87f00e0fe6e43 (diff) |
Merge pull request #5184 from freddiewanah/master
Enhancement: Refactor Test Code for Efficiency and Quality
-rw-r--r-- | docs/changelog.rst | 1 | ||||
-rw-r--r-- | test/plugins/test_art.py | 8 | ||||
-rw-r--r-- | test/plugins/test_bareasc.py | 129 | ||||
-rw-r--r-- | test/plugins/test_export.py | 8 | ||||
-rw-r--r-- | test/plugins/test_fetchart.py | 6 | ||||
-rw-r--r-- | test/plugins/test_keyfinder.py | 2 | ||||
-rw-r--r-- | test/plugins/test_lyrics.py | 11 | ||||
-rw-r--r-- | test/plugins/test_smartplaylist.py | 4 | ||||
-rw-r--r-- | test/plugins/test_spotify.py | 8 | ||||
-rw-r--r-- | test/plugins/test_types_plugin.py | 4 | ||||
-rw-r--r-- | test/plugins/test_zero.py | 8 | ||||
-rw-r--r-- | test/test_art_resize.py | 4 | ||||
-rw-r--r-- | test/test_autotag.py | 18 | ||||
-rw-r--r-- | test/test_config_command.py | 4 | ||||
-rw-r--r-- | test/test_dbcore.py | 12 | ||||
-rw-r--r-- | test/test_files.py | 10 | ||||
-rw-r--r-- | test/test_importer.py | 50 | ||||
-rw-r--r-- | test/test_library.py | 60 | ||||
-rw-r--r-- | test/test_mb.py | 14 | ||||
-rw-r--r-- | test/test_plugins.py | 8 | ||||
-rw-r--r-- | test/test_query.py | 2 | ||||
-rw-r--r-- | test/test_sort.py | 2 | ||||
-rw-r--r-- | test/test_ui.py | 70 | ||||
-rw-r--r-- | test/test_ui_commands.py | 2 | ||||
-rw-r--r-- | test/test_util.py | 20 |
25 files changed, 204 insertions, 261 deletions
diff --git a/docs/changelog.rst b/docs/changelog.rst index c0a7c0b41..6823f5cce 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -342,6 +342,7 @@ Other changes: :bug:`4585` * :doc:`/faq`: :ref:`multidisc`: Elaborated the multi-disc FAQ :bug:`4806` * :doc:`/faq`: :ref:`src`: Removed some long lines. +* Refactor the test cases to avoid test smells. 1.6.0 (November 27, 2021) ------------------------- diff --git a/test/plugins/test_art.py b/test/plugins/test_art.py index b2d1d74b4..30f08d50f 100644 --- a/test/plugins/test_art.py +++ b/test/plugins/test_art.py @@ -225,12 +225,12 @@ class FetchImageTest(FetchImageHelper, UseThePlugin): def test_invalid_type_returns_none(self): self.mock_response(self.URL, "image/watercolour") self.source.fetch_image(self.candidate, self.settings) - self.assertEqual(self.candidate.path, None) + self.assertIsNone(self.candidate.path) def test_jpeg_type_returns_path(self): self.mock_response(self.URL, "image/jpeg") self.source.fetch_image(self.candidate, self.settings) - self.assertNotEqual(self.candidate.path, None) + self.assertIsNotNone(self.candidate.path) def test_extension_set_by_content_type(self): self.mock_response(self.URL, "image/png") @@ -600,7 +600,7 @@ class CoverArtArchiveTest(UseThePlugin, CAAHelper): candidates = list(self.source.get(album, self.settings, [])) self.assertEqual(len(candidates), 3) for candidate in candidates: - self.assertTrue(f"-{maxwidth}.jpg" in candidate.url) + self.assertIn(f"-{maxwidth}.jpg", candidate.url) def test_caa_finds_image_if_maxwidth_is_set_and_thumbnails_is_empty(self): # CAA provides pre-sized thumbnails of width 250px, 500px, and 1200px @@ -621,7 +621,7 @@ class CoverArtArchiveTest(UseThePlugin, CAAHelper): candidates = list(self.source.get(album, self.settings, [])) self.assertEqual(len(candidates), 3) for candidate in candidates: - self.assertFalse(f"-{maxwidth}.jpg" in candidate.url) + self.assertNotIn(f"-{maxwidth}.jpg", candidate.url) class FanartTVTest(UseThePlugin): diff --git a/test/plugins/test_bareasc.py b/test/plugins/test_bareasc.py index 59ac0d216..66d8495e5 100644 --- a/test/plugins/test_bareasc.py +++ b/test/plugins/test_bareasc.py @@ -3,7 +3,6 @@ """Tests for the 'bareasc' plugin.""" - import unittest from beets import logging @@ -28,96 +27,44 @@ class BareascPluginTest(unittest.TestCase, TestHelper): self.add_item(title="without umlaut or e", artist="Bruggen") self.add_item(title="without umlaut with e", artist="Brueggen") - def test_search_normal_noaccent(self): - """Normal search, no accents, not using bare-ASCII match. - - Finds just the unaccented entry. - """ - items = self.lib.items("dvorak") - - self.assertEqual(len(items), 1) - self.assertEqual([items[0].title], ["without accents"]) - - def test_search_normal_accent(self): - """Normal search, with accents, not using bare-ASCII match. - - Finds just the accented entry. - """ - items = self.lib.items("dvořák") - - self.assertEqual(len(items), 1) - self.assertEqual([items[0].title], ["with accents"]) - - def test_search_bareasc_noaccent(self): - """Bare-ASCII search, no accents. - - Finds both entries. - """ - items = self.lib.items("#dvorak") - - self.assertEqual(len(items), 2) - self.assertEqual( - {items[0].title, items[1].title}, - {"without accents", "with accents"}, - ) - - def test_search_bareasc_accent(self): - """Bare-ASCII search, with accents. - - Finds both entries. - """ - items = self.lib.items("#dvořák") - - self.assertEqual(len(items), 2) - self.assertEqual( - {items[0].title, items[1].title}, - {"without accents", "with accents"}, - ) - - def test_search_bareasc_wrong_accent(self): - """Bare-ASCII search, with incorrect accent. - - Finds both entries. - """ - items = self.lib.items("#dvořäk") - - self.assertEqual(len(items), 2) - self.assertEqual( - {items[0].title, items[1].title}, - {"without accents", "with accents"}, - ) - - def test_search_bareasc_noumlaut(self): - """Bare-ASCII search, with no umlaut. - - Finds entry with 'u' not 'ue', although German speaker would - normally replace ü with ue. - - This is expected behaviour for this simple plugin. - """ - items = self.lib.items("#Bruggen") - - self.assertEqual(len(items), 2) - self.assertEqual( - {items[0].title, items[1].title}, - {"without umlaut or e", "with umlaut"}, - ) - - def test_search_bareasc_umlaut(self): - """Bare-ASCII search, with umlaut. - - Finds entry with 'u' not 'ue', although German speaker would - normally replace ü with ue. - - This is expected behaviour for this simple plugin. - """ - items = self.lib.items("#Brüggen") - - self.assertEqual(len(items), 2) - self.assertEqual( - {items[0].title, items[1].title}, - {"without umlaut or e", "with umlaut"}, - ) + def test_bareasc_search(self): + test_cases = [ + ( + "dvorak", + ["without accents"], + ), # Normal search, no accents, not using bare-ASCII match. + ( + "dvořák", + ["with accents"], + ), # Normal search, with accents, not using bare-ASCII match. + ( + "#dvorak", + ["without accents", "with accents"], + ), # Bare-ASCII search, no accents. + ( + "#dvořák", + ["without accents", "with accents"], + ), # Bare-ASCII search, with accents. + ( + "#dvořäk", + ["without accents", "with accents"], + ), # Bare-ASCII search, with incorrect accent. + ( + "#Bruggen", + ["without umlaut or e", "with umlaut"], + ), # Bare-ASCII search, with no umlaut. + ( + "#Brüggen", + ["without umlaut or e", "with umlaut"], + ), # Bare-ASCII search, with umlaut. + ] + + for query, expected_titles in test_cases: + with self.subTest(query=query, expected_titles=expected_titles): + items = self.lib.items(query) + self.assertListEqual( + [item.title for item in items], expected_titles + ) def test_bareasc_list_output(self): """Bare-ASCII version of list command - check output.""" diff --git a/test/plugins/test_export.py b/test/plugins/test_export.py index 977184bb0..b949fe4f8 100644 --- a/test/plugins/test_export.py +++ b/test/plugins/test_export.py @@ -56,7 +56,7 @@ class ExportPluginTest(unittest.TestCase, TestHelper): out = self.execute_command(format_type="json", artist=item1.artist) json_data = json.loads(out)[0] for key, val in self.test_values.items(): - self.assertTrue(key in json_data) + self.assertIn(key, json_data) self.assertEqual(val, json_data[key]) def test_jsonlines_output(self): @@ -64,7 +64,7 @@ class ExportPluginTest(unittest.TestCase, TestHelper): out = self.execute_command(format_type="jsonlines", artist=item1.artist) json_data = json.loads(out) for key, val in self.test_values.items(): - self.assertTrue(key in json_data) + self.assertIn(key, json_data) self.assertEqual(val, json_data[key]) def test_csv_output(self): @@ -74,7 +74,7 @@ class ExportPluginTest(unittest.TestCase, TestHelper): head = re.split(",", csv_list[0]) vals = re.split(",|\r", csv_list[1]) for index, column in enumerate(head): - self.assertTrue(self.test_values.get(column, None) is not None) + self.assertIsNotNone(self.test_values.get(column, None)) self.assertEqual(vals[index], self.test_values[column]) def test_xml_output(self): @@ -86,7 +86,7 @@ class ExportPluginTest(unittest.TestCase, TestHelper): for details in track: tag = details.tag txt = details.text - self.assertTrue(tag in self.test_values, msg=tag) + self.assertIn(tag, self.test_values, msg=tag) self.assertEqual(self.test_values[tag], txt, msg=txt) diff --git a/test/plugins/test_fetchart.py b/test/plugins/test_fetchart.py index c651924af..b3307472a 100644 --- a/test/plugins/test_fetchart.py +++ b/test/plugins/test_fetchart.py @@ -60,14 +60,14 @@ class FetchartCliTest(unittest.TestCase, TestHelper): os.makedirs(os.path.join(self.album.path, b"mycover.jpg")) self.run_command("fetchart") self.album.load() - self.assertEqual(self.album["artpath"], None) + self.assertIsNone(self.album["artpath"]) def test_filesystem_does_not_pick_up_ignored_file(self): self.touch(b"co_ver.jpg", dir=self.album.path, content="IMAGE") self.config["ignore"] = ["*_*"] self.run_command("fetchart") self.album.load() - self.assertEqual(self.album["artpath"], None) + self.assertIsNone(self.album["artpath"]) def test_filesystem_picks_up_non_ignored_file(self): self.touch(b"cover.jpg", dir=self.album.path, content="IMAGE") @@ -84,7 +84,7 @@ class FetchartCliTest(unittest.TestCase, TestHelper): self.config["ignore_hidden"] = True self.run_command("fetchart") self.album.load() - self.assertEqual(self.album["artpath"], None) + self.assertIsNone(self.album["artpath"]) def test_filesystem_picks_up_non_hidden_file(self): self.touch(b"cover.jpg", dir=self.album.path, content="IMAGE") diff --git a/test/plugins/test_keyfinder.py b/test/plugins/test_keyfinder.py index 84d66dfeb..8509fe357 100644 --- a/test/plugins/test_keyfinder.py +++ b/test/plugins/test_keyfinder.py @@ -82,7 +82,7 @@ class KeyFinderTest(unittest.TestCase, TestHelper): self.run_command("keyfinder") item.load() - self.assertEqual(item["initial_key"], None) + self.assertIsNone(item["initial_key"]) def suite(): diff --git a/test/plugins/test_lyrics.py b/test/plugins/test_lyrics.py index 108f299fb..11a8ff418 100644 --- a/test/plugins/test_lyrics.py +++ b/test/plugins/test_lyrics.py @@ -419,11 +419,10 @@ class LyricsGooglePluginMachineryTest(LyricsGoogleBaseTest, LyricsAssertions): soup = BeautifulSoup( html, "html.parser", parse_only=SoupStrainer("title") ) - self.assertEqual( + self.assertTrue( google.is_page_candidate( url, soup.title.string, s["title"], s["artist"] ), - True, url, ) @@ -436,16 +435,14 @@ class LyricsGooglePluginMachineryTest(LyricsGoogleBaseTest, LyricsAssertions): url_title = "example.com | Beats song by John doe" # very small diffs (typo) are ok eg 'beats' vs 'beets' with same artist - self.assertEqual( + self.assertTrue( google.is_page_candidate(url, url_title, s["title"], s["artist"]), - True, url, ) # reject different title url_title = "example.com | seets bong lyrics by John doe" - self.assertEqual( + self.assertFalse( google.is_page_candidate(url, url_title, s["title"], s["artist"]), - False, url, ) @@ -489,7 +486,7 @@ class GeniusScrapeLyricsFromHtmlTest(GeniusBaseTest): # expected return value None url = "https://genius.com/sample" mock = MockFetchUrl() - self.assertEqual(genius._scrape_lyrics_from_html(mock(url)), None) + self.assertIsNone(genius._scrape_lyrics_from_html(mock(url))) def test_good_lyrics(self): """Ensure we are able to scrape a page with lyrics""" diff --git a/test/plugins/test_smartplaylist.py b/test/plugins/test_smartplaylist.py index 470350f03..a3265f608 100644 --- a/test/plugins/test_smartplaylist.py +++ b/test/plugins/test_smartplaylist.py @@ -33,8 +33,8 @@ from beetsplug.smartplaylist import SmartPlaylistPlugin class SmartPlaylistTest(_common.TestCase): def test_build_queries(self): spl = SmartPlaylistPlugin() - self.assertEqual(spl._matched_playlists, None) - self.assertEqual(spl._unmatched_playlists, None) + self.assertIsNone(spl._matched_playlists) + self.assertIsNone(spl._unmatched_playlists) config["smartplaylist"]["playlists"].set([]) spl.build_queries() diff --git a/test/plugins/test_spotify.py b/test/plugins/test_spotify.py index 59c604a5f..ae5ce5228 100644 --- a/test/plugins/test_spotify.py +++ b/test/plugins/test_spotify.py @@ -51,14 +51,12 @@ class SpotifyPluginTest(_common.TestCase, TestHelper): def test_args(self): opts = ArgumentsMock("fail", True) - self.assertEqual(False, self.spotify._parse_opts(opts)) + self.assertFalse(self.spotify._parse_opts(opts)) opts = ArgumentsMock("list", False) - self.assertEqual(True, self.spotify._parse_opts(opts)) + self.assertTrue(self.spotify._parse_opts(opts)) def test_empty_query(self): - self.assertEqual( - None, self.spotify._match_library_tracks(self.lib, "1=2") - ) + self.assertIsNone(self.spotify._match_library_tracks(self.lib, "1=2")) @responses.activate def test_missing_request(self): diff --git a/test/plugins/test_types_plugin.py b/test/plugins/test_types_plugin.py index 1726fbf6f..8225c3302 100644 --- a/test/plugins/test_types_plugin.py +++ b/test/plugins/test_types_plugin.py @@ -92,12 +92,12 @@ class TypesPluginTest(unittest.TestCase, TestHelper): # Set true self.modify("mybool=1", "artist:true") true.load() - self.assertEqual(true["mybool"], True) + self.assertTrue(true["mybool"]) # Set false self.modify("mybool=false", "artist:false") false.load() - self.assertEqual(false["mybool"], False) + self.assertFalse(false["mybool"]) # Query bools out = self.list("mybool:true", "$artist $mybool") diff --git a/test/plugins/test_zero.py b/test/plugins/test_zero.py index f48675c5c..378e419d5 100644 --- a/test/plugins/test_zero.py +++ b/test/plugins/test_zero.py @@ -137,7 +137,7 @@ class ZeroPluginTest(unittest.TestCase, TestHelper): self.assertEqual(item["year"], 2016) self.assertEqual(mf.year, 2016) - self.assertEqual(mf.comments, None) + self.assertIsNone(mf.comments) self.assertEqual(item["comments"], "") def test_subcommand_update_database_false(self): @@ -161,7 +161,7 @@ class ZeroPluginTest(unittest.TestCase, TestHelper): self.assertEqual(item["year"], 2016) self.assertEqual(mf.year, 2016) self.assertEqual(item["comments"], "test comment") - self.assertEqual(mf.comments, None) + self.assertIsNone(mf.comments) def test_subcommand_query_include(self): item = self.add_item_fixture( @@ -180,7 +180,7 @@ class ZeroPluginTest(unittest.TestCase, TestHelper): mf = MediaFile(syspath(item.path)) self.assertEqual(mf.year, 2016) - self.assertEqual(mf.comments, None) + self.assertIsNone(mf.comments) def test_subcommand_query_exclude(self): item = self.add_item_fixture( @@ -251,7 +251,7 @@ class ZeroPluginTest(unittest.TestCase, TestHelper): z = ZeroPlugin() z.write_event(item, item.path, tags) - self.assertEqual(tags["comments"], None) + self.assertIsNone(tags["comments"]) self.assertEqual(tags["year"], 2016) def test_keep_fields_removes_preserved_tags(self): diff --git a/test/test_art_resize.py b/test/test_art_resize.py index 2f426a1dd..5cb1e7e69 100644 --- a/test/test_art_resize.py +++ b/test/test_art_resize.py @@ -129,7 +129,7 @@ class ArtResizerFileSizeTest(_common.TestCase, TestHelper): from PIL import Image with Image.open(path) as img: - self.assertFalse("progression" in img.info) + self.assertNotIn("progression", img.info) @unittest.skipUnless(IMBackend.available(), "ImageMagick not available") def test_im_file_deinterlace(self): @@ -146,7 +146,7 @@ class ArtResizerFileSizeTest(_common.TestCase, TestHelper): syspath(path, prefix=False), ] out = command_output(cmd).stdout - self.assertTrue(out == b"None") + self.assertEqual(out, b"None") @patch("beets.util.artresizer.util") def test_write_metadata_im(self, mock_util): diff --git a/test/test_autotag.py b/test/test_autotag.py index 6691348ed..868138411 100644 --- a/test/test_autotag.py +++ b/test/test_autotag.py @@ -42,7 +42,7 @@ class PluralityTest(_common.TestCase): def test_plurality_conflict(self): objs = [1, 1, 2, 2, 3] obj, freq = plurality(objs) - self.assertTrue(obj in (1, 2)) + self.assertIn(obj, (1, 2)) self.assertEqual(freq, 2) def test_plurality_empty_sequence_raises_error(self): @@ -279,9 +279,9 @@ class DistanceTest(_common.TestCase): dist.add("medium", 0.75) self.assertEqual(len(dist), 2) self.assertEqual(list(dist), [("album", 0.2), ("medium", 0.2)]) - self.assertTrue(dist == 0.4) - self.assertTrue(dist < 1.0) - self.assertTrue(dist > 0.0) + self.assertEqual(dist, 0.4) + self.assertLess(dist, 1.0) + self.assertGreater(dist, 0.0) self.assertEqual(dist - 0.4, 0.0) self.assertEqual(0.4 - dist, 0.0) self.assertEqual(float(dist), 0.4) @@ -394,7 +394,7 @@ class AlbumDistanceTest(_common.TestCase): dist = self._dist(items, info) self.assertNotEqual(dist, 0) # Make sure the distance is not too great - self.assertTrue(dist < 0.2) + self.assertLess(dist, 0.2) def test_global_artists_differ(self): items = [] @@ -1017,17 +1017,17 @@ class StringDistanceTest(unittest.TestCase): def test_leading_the_has_lower_weight(self): dist1 = string_dist("XXX Band Name", "Band Name") dist2 = string_dist("The Band Name", "Band Name") - self.assertTrue(dist2 < dist1) + self.assertLess(dist2, dist1) def test_parens_have_lower_weight(self): dist1 = string_dist("One .Two.", "One") dist2 = string_dist("One (Two)", "One") - self.assertTrue(dist2 < dist1) + self.assertLess(dist2, dist1) def test_brackets_have_lower_weight(self): dist1 = string_dist("One .Two.", "One") dist2 = string_dist("One [Two]", "One") - self.assertTrue(dist2 < dist1) + self.assertLess(dist2, dist1) def test_ep_label_has_zero_weight(self): dist = string_dist("My Song (EP)", "My Song") @@ -1036,7 +1036,7 @@ class StringDistanceTest(unittest.TestCase): def test_featured_has_lower_weight(self): dist1 = string_dist("My Song blah Someone", "My Song") dist2 = string_dist("My Song feat Someone", "My Song") - self.assertTrue(dist2 < dist1) + self.assertLess(dist2, dist1) def test_postfix_the(self): dist = string_dist("The Song Title", "Song Title, The") diff --git a/test/test_config_command.py b/test/test_config_command.py index f4220afcc..553c985da 100644 --- a/test/test_config_command.py +++ b/test/test_config_command.py @@ -53,7 +53,7 @@ class ConfigCommandTest(unittest.TestCase, TestHelper): self.assertEqual(output["option"], "value") self.assertEqual(output["password"], "password_value") self.assertEqual(output["library"], "lib") - self.assertEqual(output["import"]["timid"], False) + self.assertFalse(output["import"]["timid"]) def test_show_user_config_with_cli(self): output = self._run_with_yaml_output( @@ -74,7 +74,7 @@ class ConfigCommandTest(unittest.TestCase, TestHelper): self.assertEqual(output["option"], "value") self.assertEqual(output["password"], "REDACTED") - self.assertEqual(output["import"]["timid"], False) + self.assertFalse(output["import"]["timid"]) def test_config_paths(self): output = self.run_with_output("config", "-p") diff --git a/test/test_dbcore.py b/test/test_dbcore.py index c98e9ceba..e5ab1910b 100644 --- a/test/test_dbcore.py +++ b/test/test_dbcore.py @@ -315,16 +315,16 @@ class ModelTest(unittest.TestCase): def test_delete_flexattr(self): model = ModelFixture1() model["foo"] = "bar" - self.assertTrue("foo" in model) + self.assertIn("foo", model) del model["foo"] - self.assertFalse("foo" in model) + self.assertNotIn("foo", model) def test_delete_flexattr_via_dot(self): model = ModelFixture1() model["foo"] = "bar" - self.assertTrue("foo" in model) + self.assertIn("foo", model) del model.foo - self.assertFalse("foo" in model) + self.assertNotIn("foo", model) def test_delete_flexattr_persists(self): model = ModelFixture1() @@ -337,7 +337,7 @@ class ModelTest(unittest.TestCase): model.store() model = self.db._get(ModelFixture1, model.id) - self.assertFalse("foo" in model) + self.assertNotIn("foo", model) def test_delete_non_existent_attribute(self): model = ModelFixture1() @@ -365,7 +365,7 @@ class ModelTest(unittest.TestCase): def test_null_value_stays_none_for_untyped_field(self): model = ModelFixture1() model.foo = None - self.assertEqual(model.foo, None) + self.assertIsNone(model.foo) def test_normalization_for_typed_flex_fields(self): model = ModelFixture1() diff --git a/test/test_files.py b/test/test_files.py index e0c8a9bf1..1b898dd9f 100644 --- a/test/test_files.py +++ b/test/test_files.py @@ -128,7 +128,7 @@ class MoveTest(_common.TestCase): self.assertIn("C_DOS", self.i.path.decode()) def test_move_file_with_multiple_colons(self): - print(beets.config["replace"]) + # print(beets.config["replace"]) self.i.artist = "COM:DOS" self.i.move() self.assertIn("COM_DOS", self.i.path.decode()) @@ -306,7 +306,7 @@ class AlbumFileTest(_common.TestCase): self.ai.move(basedir=self.otherdir) self.i.load() self.ai.store() - self.assertTrue(b"testotherdir" in self.i.path) + self.assertIn(b"testotherdir", self.i.path) class ArtFileTest(_common.TestCase): @@ -359,7 +359,7 @@ class ArtFileTest(_common.TestCase): self.assertNotExists(self.art) newart = self.lib.get_album(self.i).artpath self.assertExists(newart) - self.assertTrue(b"testotherdir" in newart) + self.assertIn(b"testotherdir", newart) def test_setart_copies_image(self): util.remove(self.art) @@ -372,7 +372,7 @@ class ArtFileTest(_common.TestCase): ai = self.lib.add_album((i2,)) i2.move(operation=MoveOperation.COPY) - self.assertEqual(ai.artpath, None) + self.assertIsNone(ai.artpath) ai.set_art(newart) self.assertExists(ai.artpath) @@ -478,7 +478,7 @@ class ArtFileTest(_common.TestCase): self.i.move() artpath = self.lib.albums()[0].artpath - self.assertFalse(b"different_album" in artpath) + self.assertNotIn(b"different_album", artpath) self.assertEqual(artpath, oldartpath) self.assertExists(oldartpath) diff --git a/test/test_importer.py b/test/test_importer.py index a381fc5f4..8809af49b 100644 --- a/test/test_importer.py +++ b/test/test_importer.py @@ -94,8 +94,8 @@ class ScrubbedImportTest(_common.TestCase, ImportHelper): for item in self.lib.items(): imported_file = os.path.join(item.path) imported_file = MediaFile(imported_file) - self.assertEqual(imported_file.artist, None) - self.assertEqual(imported_file.album, None) + self.assertIsNone(imported_file.artist) + self.assertIsNone(imported_file.album) @_common.slow_test() @@ -337,18 +337,18 @@ class ImportSingletonTest(_common.TestCase, ImportHelper): self.matcher.restore() def test_apply_asis_adds_track(self): - self.assertEqual(self.lib.items().get(), None) + self.assertIsNone(self.lib.items().get()) self.importer.add_choice(importer.action.ASIS) self.importer.run() self.assertEqual(self.lib.items().get().title, "Tag Title 1") def test_apply_asis_does_not_add_album(self): - self.assertEqual(self.lib.albums().get(), None) + self.assertIsNone(self.lib.albums().get()) self.importer.add_choice(importer.action.ASIS) self.importer.run() - self.assertEqual(self.lib.albums().get(), None) + self.assertIsNone(self.lib.albums().get()) def test_apply_asis_adds_singleton_path(self): self.assert_lib_dir_empty() @@ -358,7 +358,7 @@ class ImportSingletonTest(_common.TestCase, ImportHelper): self.assert_file_in_lib(b"singletons", b"Tag Title 1.mp3") def test_apply_candidate_adds_track(self): - self.assertEqual(self.lib.items().get(), None) + self.assertIsNone(self.lib.items().get()) self.importer.add_choice(importer.action.APPLY) self.importer.run() @@ -367,7 +367,7 @@ class ImportSingletonTest(_common.TestCase, ImportHelper): def test_apply_candidate_does_not_add_album(self): self.importer.add_choice(importer.action.APPLY) self.importer.run() - self.assertEqual(self.lib.albums().get(), None) + self.assertIsNone(self.lib.albums().get()) def test_apply_candidate_adds_singleton_path(self): self.assert_lib_dir_empty() @@ -379,7 +379,7 @@ class ImportSingletonTest(_common.TestCase, ImportHelper): def test_skip_does_not_add_first_track(self): self.importer.add_choice(importer.action.SKIP) self.importer.run() - self.assertEqual(self.lib.items().get(), None) + self.assertIsNone(self.lib.items().get()) def test_skip_adds_other_tracks(self): self._create_import_dir(2) @@ -418,7 +418,7 @@ class ImportSingletonTest(_common.TestCase, ImportHelper): } # As-is item import. - self.assertEqual(self.lib.albums().get(), None) + self.assertIsNone(self.lib.albums().get()) self.importer.add_choice(importer.action.ASIS) self.importer.run() @@ -431,7 +431,7 @@ class ImportSingletonTest(_common.TestCase, ImportHelper): item.remove() # Autotagged. - self.assertEqual(self.lib.albums().get(), None) + self.assertIsNone(self.lib.albums().get()) |