diff --git a/test/plugins/test_beatport.py b/test/plugins/test_beatport.py index 57625e0c11..d072340b5e 100644 --- a/test/plugins/test_beatport.py +++ b/test/plugins/test_beatport.py @@ -12,8 +12,7 @@ # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. -"""Tests for the 'beatport' plugin. -""" +"""Tests for the 'beatport' plugin.""" from datetime import timedelta @@ -570,11 +569,7 @@ def test_track_url_applied(self): # Concatenate with 'id' to pass strict equality test. for track, test_track, id in zip(self.tracks, self.test_tracks, ids): assert ( - track.url - == "https://beatport.com/track/" - + test_track.url - + "/" - + str(id) + track.url == f"https://beatport.com/track/{test_track.url}/{id}" ) def test_bpm_applied(self): diff --git a/test/plugins/test_convert.py b/test/plugins/test_convert.py index 0a7d49bd65..67f6fcd04e 100644 --- a/test/plugins/test_convert.py +++ b/test/plugins/test_convert.py @@ -64,9 +64,9 @@ def assertFileTag(self, path, tag): # noqa self.assertIsFile(path) with open(path, "rb") as f: f.seek(-len(display_tag), os.SEEK_END) - assert f.read() == tag, "{} is not tagged with {}".format( - displayable_path(path), display_tag - ) + assert ( + f.read() == tag + ), f"{displayable_path(path)} is not tagged with {display_tag}" def assertNoFileTag(self, path, tag): # noqa """Assert that the path is a file and the files content does not @@ -77,9 +77,9 @@ def assertNoFileTag(self, path, tag): # noqa self.assertIsFile(path) with open(path, "rb") as f: f.seek(-len(tag), os.SEEK_END) - assert f.read() != tag, "{} is unexpectedly tagged with {}".format( - displayable_path(path), display_tag - ) + assert ( + f.read() != tag + ), f"{displayable_path(path)} is unexpectedly tagged with {display_tag}" class ConvertTestCase(ConvertMixin, PluginTestCase): @@ -123,9 +123,7 @@ def test_delete_originals(self): for root, dirnames, filenames in os.walk(path): assert ( len(fnmatch.filter(filenames, "*.mp3")) == 0 - ), "Non-empty import directory {}".format( - util.displayable_path(path) - ) + ), f"Non-empty import directory {util.displayable_path(path)}" def get_count_of_import_files(self): import_file_count = 0 diff --git a/test/plugins/test_embedart.py b/test/plugins/test_embedart.py index 7ccbcc52ff..b20ff6c87e 100644 --- a/test/plugins/test_embedart.py +++ b/test/plugins/test_embedart.py @@ -155,9 +155,7 @@ def test_reject_different_art(self): assert ( mediafile.images[0].data == self.image_data - ), "Image written is not {}".format( - displayable_path(self.abbey_artpath) - ) + ), f"Image written is not {displayable_path(self.abbey_artpath)}" @require_artresizer_compare def test_accept_similar_art(self): @@ -171,9 +169,7 @@ def test_accept_similar_art(self): assert ( mediafile.images[0].data == self.image_data - ), "Image written is not {}".format( - displayable_path(self.abbey_similarpath) - ) + ), f"Image written is not {displayable_path(self.abbey_similarpath)}" def test_non_ascii_album_path(self): resource_path = os.path.join(_common.RSRC, b"image.mp3") diff --git a/test/plugins/test_play.py b/test/plugins/test_play.py index 88ef88c84b..63f20aeefc 100644 --- a/test/plugins/test_play.py +++ b/test/plugins/test_play.py @@ -98,8 +98,7 @@ def test_use_folders(self, open_mock): with open(open_mock.call_args[0][0][0], "rb") as f: playlist = f.read().decode("utf-8") assert ( - "{}\n".format(os.path.dirname(self.item.path.decode("utf-8"))) - == playlist + f'{os.path.dirname(self.item.path.decode("utf-8"))}\n' == playlist ) def test_raw(self, open_mock): diff --git a/test/plugins/test_player.py b/test/plugins/test_player.py index e93a742a24..bf466e1b5b 100644 --- a/test/plugins/test_player.py +++ b/test/plugins/test_player.py @@ -378,7 +378,7 @@ def run_bpd( def _assert_ok(self, *responses): for response in responses: assert response is not None - assert response.ok, "Response failed: {}".format(response.err_data) + assert response.ok, f"Response failed: {response.err_data}" def _assert_failed(self, response, code, pos=None): """Check that a command failed with a specific error code. If this diff --git a/test/test_autotag.py b/test/test_autotag.py index 147a2b7bdb..7e6e7f43e9 100644 --- a/test/test_autotag.py +++ b/test/test_autotag.py @@ -98,16 +98,13 @@ def test_current_metadata_likelies(self): "media", "albumdisambig", ] - items = [ - Item(**{f: "{}_{}".format(f, i or 1) for f in fields}) - for i in range(5) - ] + items = [Item(**{f: f"{f}_{i or 1}" for f in fields}) for i in range(5)] likelies, _ = match.current_metadata(items) for f in fields: if isinstance(likelies[f], int): assert likelies[f] == 0 else: - assert likelies[f] == "%s_1" % f + assert likelies[f] == f"{f}_1" def _make_item(title, track, artist="some artist"): diff --git a/test/test_plugins.py b/test/test_plugins.py index ca75039507..cb8d8e0d5e 100644 --- a/test/test_plugins.py +++ b/test/test_plugins.py @@ -175,11 +175,9 @@ def test_import_task_created(self): logs = [line for line in logs if not line.startswith("Sending event:")] assert logs == [ - "Album: {}".format( - displayable_path(os.path.join(self.import_dir, b"album")) - ), - " {}".format(displayable_path(self.import_media[0].path)), - " {}".format(displayable_path(self.import_media[1].path)), + f'Album: {displayable_path(os.path.join(self.import_dir, b"album"))}', + f" {displayable_path(self.import_media[0].path)}", + f" {displayable_path(self.import_media[1].path)}", ] def test_import_task_created_with_plugin(self): @@ -219,8 +217,8 @@ def import_task_created_event(self, session, task): logs = [line for line in logs if not line.startswith("Sending event:")] assert logs == [ - "Singleton: {}".format(displayable_path(self.import_media[0].path)), - "Singleton: {}".format(displayable_path(self.import_media[1].path)), + f"Singleton: {displayable_path(self.import_media[0].path)}", + f"Singleton: {displayable_path(self.import_media[1].path)}", ] diff --git a/test/test_query.py b/test/test_query.py index e8aeb85ae3..04170a1598 100644 --- a/test/test_query.py +++ b/test/test_query.py @@ -690,7 +690,7 @@ def test_detect_absolute_path(self): assert is_path_query(parent) # Some non-existent path. - assert not is_path_query(path_str + "baz") + assert not is_path_query(f"{path_str}baz") def test_detect_relative_path(self): """Test detection of implicit path queries based on whether or diff --git a/test/test_template.py b/test/test_template.py index ef001bf7ab..23bf527a0e 100644 --- a/test/test_template.py +++ b/test/test_template.py @@ -53,30 +53,18 @@ def test_empty_string(self): def _assert_symbol(self, obj, ident): """Assert that an object is a Symbol with the given identifier.""" - assert isinstance(obj, functemplate.Symbol), "not a Symbol: %s" % repr( - obj - ) - assert obj.ident == ident, "wrong identifier: %s vs. %s" % ( - repr(obj.ident), - repr(ident), - ) + assert isinstance(obj, functemplate.Symbol), f"not a Symbol: {obj}" + assert obj.ident == ident, f"wrong identifier: {obj.ident} vs. {ident}" def _assert_call(self, obj, ident, numargs): """Assert that an object is a Call with the given identifier and argument count. """ - assert isinstance(obj, functemplate.Call), "not a Call: %s" % repr(obj) - assert obj.ident == ident, "wrong identifier: %s vs. %s" % ( - repr(obj.ident), - repr(ident), - ) + assert isinstance(obj, functemplate.Call), f"not a Call: {obj}" + assert obj.ident == ident, f"wrong identifier: {obj.ident} vs. {ident}" assert ( len(obj.args) == numargs - ), "wrong argument count in %s: %i vs. %i" % ( - repr(obj.ident), - len(obj.args), - numargs, - ) + ), f"wrong argument count in {obj.ident}: {len(obj.args)} vs. {numargs}" def test_plain_text(self): assert list(_normparse("hello world")) == ["hello world"]