diff --git a/test/plugins/test_art.py b/test/plugins/test_art.py index 3c8411bc1..a810cdaf5 100644 --- a/test/plugins/test_art.py +++ b/test/plugins/test_art.py @@ -605,7 +605,7 @@ class CoverArtArchiveTest(UseThePlugin, CAAHelper): candidates = list(self.source.get(album, self.settings, [])) self.assertEqual(len(candidates), 3) for candidate in candidates: - self.assertNotIn(f"-{maxwidth}.jpg", candidate.url) + assert f"-{maxwidth}.jpg" not in candidate.url class FanartTVTest(UseThePlugin): diff --git a/test/plugins/test_info.py b/test/plugins/test_info.py index 91778ed47..e061a6559 100644 --- a/test/plugins/test_info.py +++ b/test/plugins/test_info.py @@ -37,7 +37,7 @@ class InfoTest(PluginTestCase): assert "albumartist: AAA" in out assert "disctitle: DDD" in out assert "genres: a; b; c" in out - self.assertNotIn("composer:", out) + assert "composer:" not in out def test_item_query(self): item1, item2 = self.add_item_fixtures(count=2) @@ -50,7 +50,7 @@ class InfoTest(PluginTestCase): assert displayable_path(item1.path) in out assert "album: xxxx" in out - self.assertNotIn(displayable_path(item2.path), out) + assert displayable_path(item2.path) not in out def test_item_library_query(self): (item,) = self.add_item_fixtures() diff --git a/test/plugins/test_lyrics.py b/test/plugins/test_lyrics.py index c636604c5..8ce2a7b8a 100644 --- a/test/plugins/test_lyrics.py +++ b/test/plugins/test_lyrics.py @@ -58,7 +58,7 @@ class LyricsPluginTest(unittest.TestCase): item = Item(artist="Alice feats Bob", title="song") assert ("Alice feats Bob", ["song"]) in lyrics.search_pairs(item) - self.assertNotIn(("Alice", ["song"]), lyrics.search_pairs(item)) + assert ("Alice", ["song"]) not in lyrics.search_pairs(item) item = Item(artist="Alice featuring Bob", title="song") assert ("Alice featuring Bob", ["song"]) in lyrics.search_pairs(item) @@ -129,8 +129,8 @@ class LyricsPluginTest(unittest.TestCase): assert ("A", ["Song featuring B"]) in lyrics.search_pairs(item) item = Item(title="Song and B", artist="A") - self.assertNotIn(("A", ["Song"]), lyrics.search_pairs(item)) assert ("A", ["Song and B"]) in lyrics.search_pairs(item) + assert ("A", ["Song"]) not in lyrics.search_pairs(item) item = Item(title="Song: B", artist="A") assert ("A", ["Song"]) in lyrics.search_pairs(item) diff --git a/test/plugins/test_player.py b/test/plugins/test_player.py index 95bf699c6..f94e2a3b5 100644 --- a/test/plugins/test_player.py +++ b/test/plugins/test_player.py @@ -461,7 +461,7 @@ class BPDQueryTest(BPDTestHelper): ) self._assert_ok(*responses) self.assertEqual("1", responses[1].data["Id"]) - self.assertNotIn("Id", responses[3].data) + assert "Id" not in responses[3].data def test_cmd_currentsong_tagtypes(self): with self.run_bpd() as client: @@ -703,7 +703,7 @@ class BPDPlaybackTest(BPDTestHelper): response = client.send_command("crossfade", "0.5") self._assert_failed(responses, bpd.ERROR_ARG, pos=3) self._assert_failed(response, bpd.ERROR_ARG) - self.assertNotIn("xfade", responses[0].data) + assert "xfade" not in responses[0].data self.assertAlmostEqual(123, int(responses[2].data["xfade"])) def test_cmd_mixrampdb(self): @@ -723,7 +723,7 @@ class BPDPlaybackTest(BPDTestHelper): ) self._assert_failed(responses, bpd.ERROR_ARG, pos=4) self.assertAlmostEqual(2, float(responses[1].data["mixrampdelay"])) - self.assertNotIn("mixrampdelay", responses[3].data) + assert "mixrampdelay" not in responses[3].data def test_cmd_setvol(self): with self.run_bpd() as client: @@ -814,7 +814,7 @@ class BPDControlTest(BPDTestHelper): ) self._assert_ok(*responses) self.assertEqual("stop", responses[2].data["state"]) - self.assertNotIn("Id", responses[3].data) + assert "Id" not in responses[3].data def test_cmd_next(self): with self.run_bpd() as client: diff --git a/test/plugins/test_web.py b/test/plugins/test_web.py index 1da223bf1..54f44ce47 100644 --- a/test/plugins/test_web.py +++ b/test/plugins/test_web.py @@ -100,7 +100,7 @@ class WebPluginTest(ItemInDBTestCase): res_json = json.loads(response.data.decode("utf-8")) self.assertEqual(response.status_code, 200) - self.assertNotIn("path", res_json) + assert "path" not in res_json def test_config_include_artpaths_false(self): web.app.config["INCLUDE_PATHS"] = False @@ -108,7 +108,7 @@ class WebPluginTest(ItemInDBTestCase): res_json = json.loads(response.data.decode("utf-8")) self.assertEqual(response.status_code, 200) - self.assertNotIn("artpath", res_json) + assert "artpath" not in res_json def test_get_all_items(self): response = self.client.get("/item/") diff --git a/test/plugins/test_zero.py b/test/plugins/test_zero.py index 582b9dc61..1f5dbbe29 100644 --- a/test/plugins/test_zero.py +++ b/test/plugins/test_zero.py @@ -226,7 +226,7 @@ class ZeroPluginTest(PluginTestCase): z = ZeroPlugin() - self.assertNotIn("id", z.fields_to_progs) + assert "id" not in z.fields_to_progs def test_fields_removes_preserved_tags(self): self.config["zero"]["fields"] = ["year id"] @@ -234,7 +234,7 @@ class ZeroPluginTest(PluginTestCase): z = ZeroPlugin() - self.assertNotIn("id", z.fields_to_progs) + assert "id" not in z.fields_to_progs def test_empty_query_n_response_no_changes(self): item = self.add_item_fixture( diff --git a/test/test_art_resize.py b/test/test_art_resize.py index 3a2d5cc83..92cb61948 100644 --- a/test/test_art_resize.py +++ b/test/test_art_resize.py @@ -123,7 +123,7 @@ class ArtResizerFileSizeTest(CleanupModulesMixin, BeetsTestCase): from PIL import Image with Image.open(path) as img: - self.assertNotIn("progression", img.info) + assert "progression" not in img.info @unittest.skipUnless(IMBackend.available(), "ImageMagick not available") def test_im_file_deinterlace(self): diff --git a/test/test_dbcore.py b/test/test_dbcore.py index 6e776f58b..8d33b07f8 100644 --- a/test/test_dbcore.py +++ b/test/test_dbcore.py @@ -316,14 +316,14 @@ class ModelTest(unittest.TestCase): model["foo"] = "bar" assert "foo" in model del model["foo"] - self.assertNotIn("foo", model) + assert "foo" not in model def test_delete_flexattr_via_dot(self): model = ModelFixture1() model["foo"] = "bar" assert "foo" in model del model.foo - self.assertNotIn("foo", model) + assert "foo" not in model def test_delete_flexattr_persists(self): model = ModelFixture1() @@ -336,7 +336,7 @@ class ModelTest(unittest.TestCase): model.store() model = self.db._get(ModelFixture1, model.id) - self.assertNotIn("foo", model) + assert "foo" not in model def test_delete_non_existent_attribute(self): model = ModelFixture1() @@ -383,7 +383,7 @@ class ModelTest(unittest.TestCase): model1.store() model2.load() - self.assertNotIn("flex_field", model2) + assert "flex_field" not in model2 def test_check_db_fails(self): with self.assertRaisesRegex(ValueError, "no database"): diff --git a/test/test_files.py b/test/test_files.py index 3844f4c76..5f6d485b7 100644 --- a/test/test_files.py +++ b/test/test_files.py @@ -471,7 +471,7 @@ class ArtFileTest(BeetsTestCase): self.i.move() artpath = self.lib.albums()[0].artpath - self.assertNotIn(b"different_album", artpath) + assert b"different_album" not in artpath self.assertEqual(artpath, oldartpath) self.assertExists(oldartpath) diff --git a/test/test_library.py b/test/test_library.py index c406eb113..c43495b70 100644 --- a/test/test_library.py +++ b/test/test_library.py @@ -50,7 +50,7 @@ class LoadTest(ItemInDBTestCase): self.i.artist = "something" assert "artist" in self.i._dirty self.i.load() - self.assertNotIn("artist", self.i._dirty) + assert "artist" not in self.i._dirty class StoreTest(ItemInDBTestCase): @@ -78,7 +78,7 @@ class StoreTest(ItemInDBTestCase): def test_store_clears_dirty_flags(self): self.i.composer = "tvp" self.i.store() - self.assertNotIn("composer", self.i._dirty) + assert "composer" not in self.i._dirty def test_store_album_cascades_flex_deletes(self): album = _common.album() @@ -90,8 +90,8 @@ class StoreTest(ItemInDBTestCase): self.lib.add(item) del album.flex1 album.store() - self.assertNotIn("flex1", album) - self.assertNotIn("flex1", album.items()[0]) + assert "flex1" not in album + assert "flex1" not in album.items()[0] class AddTest(BeetsTestCase): @@ -147,7 +147,7 @@ class GetSetTest(BeetsTestCase): def test_set_does_not_dirty_if_value_unchanged(self): self.i.title = self.i.title - self.assertNotIn("title", self.i._dirty) + assert "title" not in self.i._dirty def test_invalid_field_raises_attributeerror(self): self.assertRaises(AttributeError, getattr, self.i, "xyzzy") @@ -160,7 +160,7 @@ class GetSetTest(BeetsTestCase): album.store() assert "flex" in i - self.assertNotIn("flex", i.keys(with_album=False)) + assert "flex" not in i.keys(with_album=False) self.assertEqual(i["flex"], "foo") self.assertEqual(i.get("flex"), "foo") assert i.get("flex", with_album=False) is None @@ -233,13 +233,13 @@ class DestinationTest(BeetsTestCase): dest = self.i.destination() assert b"one" in dest assert b"two" in dest - self.assertNotIn(b"one/two", dest) + assert b"one/two" not in dest def test_destination_escapes_leading_dot(self): self.i.album = ".something" dest = self.i.destination() assert b"something" in dest - self.assertNotIn(b"/.something", dest) + assert b"/.something" not in dest def test_destination_preserves_legitimate_slashes(self): self.i.artist = "one" @@ -263,10 +263,10 @@ class DestinationTest(BeetsTestCase): self.i.title = "one \\ two / three.mp3" with _common.platform_windows(): p = self.i.destination() - self.assertNotIn(b"one \\ two", p) - self.assertNotIn(b"one / two", p) - self.assertNotIn(b"two \\ three", p) - self.assertNotIn(b"two / three", p) + assert b"one \\ two" not in p + assert b"one / two" not in p + assert b"two \\ three" not in p + assert b"two / three" not in p def test_path_with_format(self): self.lib.path_formats = [("default", "$artist/$album ($format)")] @@ -427,7 +427,7 @@ class DestinationTest(BeetsTestCase): self.i.title = "h\u0259d" self.lib.path_formats = [("default", "$title")] p = self.i.destination() - self.assertNotIn(b"?", p) + assert b"?" not in p # We use UTF-8 to encode Windows paths now. assert "h\u0259d".encode() in p finally: diff --git a/test/test_logging.py b/test/test_logging.py index 1608897d0..5a377b3f2 100644 --- a/test/test_logging.py +++ b/test/test_logging.py @@ -88,7 +88,7 @@ class LoggingLevelTest(AsIsImporterMixin, PluginMixin, ImportTestCase): self.run_command("dummy") assert "dummy: warning cmd" in logs assert "dummy: info cmd" in logs - self.assertNotIn("dummy: debug cmd", logs) + assert "dummy: debug cmd" not in logs def test_command_level1(self): self.config["verbose"] = 1 @@ -111,8 +111,8 @@ class LoggingLevelTest(AsIsImporterMixin, PluginMixin, ImportTestCase): with helper.capture_log() as logs: plugins.send("dummy_event") assert "dummy: warning listener" in logs - self.assertNotIn("dummy: info listener", logs) - self.assertNotIn("dummy: debug listener", logs) + assert "dummy: info listener" not in logs + assert "dummy: debug listener" not in logs def test_listener_level1(self): self.config["verbose"] = 1 @@ -120,7 +120,7 @@ class LoggingLevelTest(AsIsImporterMixin, PluginMixin, ImportTestCase): plugins.send("dummy_event") assert "dummy: warning listener" in logs assert "dummy: info listener" in logs - self.assertNotIn("dummy: debug listener", logs) + assert "dummy: debug listener" not in logs def test_listener_level2(self): self.config["verbose"] = 2 @@ -135,8 +135,8 @@ class LoggingLevelTest(AsIsImporterMixin, PluginMixin, ImportTestCase): with helper.capture_log() as logs: self.run_asis_importer() assert "dummy: warning import_stage" in logs - self.assertNotIn("dummy: info import_stage", logs) - self.assertNotIn("dummy: debug import_stage", logs) + assert "dummy: info import_stage" not in logs + assert "dummy: debug import_stage" not in logs def test_import_stage_level1(self): self.config["verbose"] = 1 @@ -144,7 +144,7 @@ class LoggingLevelTest(AsIsImporterMixin, PluginMixin, ImportTestCase): self.run_asis_importer() assert "dummy: warning import_stage" in logs assert "dummy: info import_stage" in logs - self.assertNotIn("dummy: debug import_stage", logs) + assert "dummy: debug import_stage" not in logs def test_import_stage_level2(self): self.config["verbose"] = 2 diff --git a/test/test_plugins.py b/test/test_plugins.py index a44700534..9fc9c5d6c 100644 --- a/test/test_plugins.py +++ b/test/test_plugins.py @@ -89,7 +89,7 @@ class ItemTypesTest(PluginLoaderTestCase): # Do not match unset values out = self.run_with_output("ls", "rating:1..3") - self.assertNotIn("aaa", out) + assert "aaa" not in out self.run_command("modify", "rating=2", "--yes") @@ -99,7 +99,7 @@ class ItemTypesTest(PluginLoaderTestCase): # Don't match out of range out = self.run_with_output("ls", "rating:3..5") - self.assertNotIn("aaa", out) + assert "aaa" not in out class ItemWriteTest(PluginLoaderTestCase): diff --git a/test/test_query.py b/test/test_query.py index 7e8436a87..41f62d8ea 100644 --- a/test/test_query.py +++ b/test/test_query.py @@ -52,7 +52,7 @@ class AssertsMixin: def assertNotInResult(self, item, results): # noqa result_ids = [i.id for i in results] - self.assertNotIn(item.id, result_ids) + assert item.id not in result_ids class AnyFieldQueryTest(ItemInDBTestCase): diff --git a/test/test_ui.py b/test/test_ui.py index 6e50e6216..9f594720a 100644 --- a/test/test_ui.py +++ b/test/test_ui.py @@ -81,16 +81,16 @@ class ListTest(BeetsTestCase): def test_list_album_omits_title(self): stdout = self._run_list(album=True) - self.assertNotIn("the title", stdout.getvalue()) + assert "the title" not in stdout.getvalue() def test_list_uses_track_artist(self): stdout = self._run_list() assert "the artist" in stdout.getvalue() - self.assertNotIn("the album artist", stdout.getvalue()) + assert "the album artist" not in stdout.getvalue() def test_list_album_uses_album_artist(self): stdout = self._run_list(album=True) - self.assertNotIn("the artist", stdout.getvalue()) + assert "the artist" not in stdout.getvalue() assert "the album artist" in stdout.getvalue() def test_list_item_format_artist(self): @@ -106,7 +106,7 @@ class ListTest(BeetsTestCase): def test_list_album_format(self): stdout = self._run_list(album=True, fmt="$genre") assert "the genre" in stdout.getvalue() - self.assertNotIn("the album", stdout.getvalue()) + assert "the album" not in stdout.getvalue() class RemoveTest(BeetsTestCase): @@ -240,13 +240,13 @@ class ModifyTest(BeetsTestCase): def test_not_move(self): self.modify("--nomove", "title=newTitle") item = self.lib.items().get() - self.assertNotIn(b"newTitle", item.path) + assert b"newTitle" not in item.path def test_no_write_no_move(self): self.modify("--nomove", "--nowrite", "title=newTitle") item = self.lib.items().get() item.read() - self.assertNotIn(b"newTitle", item.path) + assert b"newTitle" not in item.path self.assertNotEqual(item.title, "newTitle") def test_update_mtime(self): @@ -323,7 +323,7 @@ class ModifyTest(BeetsTestCase): self.modify("--nomove", "--album", "album=newAlbum") item = self.lib.items().get() item.read() - self.assertNotIn(b"newAlbum", item.path) + assert b"newAlbum" not in item.path def test_modify_album_formatted(self): item = self.lib.items().get() @@ -352,7 +352,7 @@ class ModifyTest(BeetsTestCase): self.modify("flexattr!") item = self.lib.items().get() - self.assertNotIn("flexattr", item) + assert "flexattr" not in item @unittest.skip("not yet implemented") def test_delete_initial_key_tag(self): @@ -637,7 +637,7 @@ class UpdateTest(BeetsTestCase): mf.save() self._update(move=False) item = self.lib.items().get() - self.assertNotIn(b"differentTitle", item.path) + assert b"differentTitle" not in item.path def test_selective_modified_metadata_moved(self): mf = MediaFile(syspath(self.i.path)) @@ -656,7 +656,7 @@ class UpdateTest(BeetsTestCase): mf.save() self._update(move=False, fields=["title"]) item = self.lib.items().get() - self.assertNotIn(b"differentTitle", item.path) + assert b"differentTitle" not in item.path self.assertNotEqual(item.genre, "differentGenre") def test_modified_album_metadata_moved(self): @@ -694,7 +694,7 @@ class UpdateTest(BeetsTestCase): mf.save() self._update(move=True, fields=["genre"]) item = self.lib.items().get() - self.assertNotIn(b"differentAlbum", item.path) + assert b"differentAlbum" not in item.path self.assertEqual(item.genre, "differentGenre") def test_mtime_match_skips_update(self): @@ -1319,7 +1319,7 @@ class ShowChangeTest(BeetsTestCase): # _common.log.info("Message:{}".format(msg)) assert "artist: another artist" in msg assert " -> the artist" in msg - self.assertNotIn("another album -> the album", msg) + assert "another album -> the album" not in msg def test_item_data_change_wrap_column(self): # Patch ui.term_width to force wrapping diff --git a/test/test_util.py b/test/test_util.py index f800d02f6..027c0aaac 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -52,28 +52,28 @@ class UtilTest(unittest.TestCase): def test_sanitize_unix_replaces_leading_dot(self): with _common.platform_posix(): p = util.sanitize_path("one/.two/three") - self.assertNotIn(".", p) + assert "." not in p def test_sanitize_windows_replaces_trailing_dot(self): with _common.platform_windows(): p = util.sanitize_path("one/two./three") - self.assertNotIn(".", p) + assert "." not in p def test_sanitize_windows_replaces_illegal_chars(self): with _common.platform_windows(): p = util.sanitize_path(':*?"<>|') - self.assertNotIn(":", p) - self.assertNotIn("*", p) - self.assertNotIn("?", p) - self.assertNotIn('"', p) - self.assertNotIn("<", p) - self.assertNotIn(">", p) - self.assertNotIn("|", p) + assert ":" not in p + assert "*" not in p + assert "?" not in p + assert '"' not in p + assert "<" not in p + assert ">" not in p + assert "|" not in p def test_sanitize_windows_replaces_trailing_space(self): with _common.platform_windows(): p = util.sanitize_path("one/two /three") - self.assertNotIn(" ", p) + assert " " not in p def test_sanitize_path_works_on_empty_string(self): with _common.platform_posix():