From cb82917fe0d5476c74bb946f91ea0d9a9f019c9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0ar=C5=ABnas=20Nejus?= Date: Mon, 29 Jul 2024 01:04:22 +0100 Subject: [PATCH] Replace assertFalse --- beets/test/_common.py | 4 +--- test/plugins/test_art.py | 2 +- test/plugins/test_convert.py | 2 +- test/plugins/test_embedart.py | 12 ++++++------ test/plugins/test_ftintitle.py | 4 ++-- test/plugins/test_ihate.py | 6 +++--- test/plugins/test_lyrics.py | 11 +++++------ test/plugins/test_mpdstats.py | 4 ++-- test/plugins/test_player.py | 2 +- test/plugins/test_smartplaylist.py | 8 ++++---- test/plugins/test_spotify.py | 2 +- test/plugins/test_thumbnails.py | 2 +- test/plugins/test_types_plugin.py | 2 +- test/plugins/test_web.py | 2 +- test/plugins/test_zero.py | 2 +- test/test_autotag.py | 8 ++++---- test/test_config_command.py | 4 ++-- test/test_datequery.py | 6 +++--- test/test_importer.py | 6 +++--- test/test_logging.py | 4 ++-- test/test_m3ufile.py | 2 +- test/test_mb.py | 12 ++++++------ test/test_metasync.py | 4 ++-- test/test_plugins.py | 5 ++--- test/test_query.py | 14 +++++++------- test/test_ui.py | 24 ++++++++++++------------ 26 files changed, 75 insertions(+), 79 deletions(-) diff --git a/beets/test/_common.py b/beets/test/_common.py index f246a04cc..642957662 100644 --- a/beets/test/_common.py +++ b/beets/test/_common.py @@ -155,9 +155,7 @@ class Assertions: assert os.path.exists(syspath(path)), f"file does not exist: {path!r}" def assertNotExists(self, path): # noqa - self.assertFalse( - os.path.exists(syspath(path)), f"file exists: {path!r}" - ) + assert not os.path.exists(syspath(path)), f"file exists: {path!r}" def assertIsFile(self, path): # noqa self.assertExists(path) diff --git a/test/plugins/test_art.py b/test/plugins/test_art.py index ce86b257f..dfb5374d5 100644 --- a/test/plugins/test_art.py +++ b/test/plugins/test_art.py @@ -314,7 +314,7 @@ class CombinedTest(FetchImageTestCase, CAAHelper): album = _common.Bag(asin=self.ASIN) candidate = self.plugin.art_for_album(album, [self.dpath]) self.assertIsNotNone(candidate) - self.assertFalse(candidate.path.startswith(self.dpath)) + assert not candidate.path.startswith(self.dpath) def test_main_interface_tries_amazon_before_aao(self): self.mock_response(self.AMAZON_URL) diff --git a/test/plugins/test_convert.py b/test/plugins/test_convert.py index 15599b891..10a8b8046 100644 --- a/test/plugins/test_convert.py +++ b/test/plugins/test_convert.py @@ -305,7 +305,7 @@ class ConvertCliTest(ConvertTestCase, ConvertCommand): def test_playlist_pretend(self): self.run_convert("--playlist", "playlist.m3u8", "--pretend") m3u_created = os.path.join(self.convert_dest, b"playlist.m3u8") - self.assertFalse(os.path.exists(m3u_created)) + assert not os.path.exists(m3u_created) @_common.slow_test() diff --git a/test/plugins/test_embedart.py b/test/plugins/test_embedart.py index f01ece25e..1716015c5 100644 --- a/test/plugins/test_embedart.py +++ b/test/plugins/test_embedart.py @@ -74,7 +74,7 @@ class EmbedartCliTest(PluginMixin, FetchImageHelper, BeetsTestCase): self.run_command("embedart", "-f", self.small_artpath) mediafile = MediaFile(syspath(item.path)) # make sure that images array is empty (nothing embedded) - self.assertFalse(mediafile.images) + assert not mediafile.images def test_embed_art_from_file(self): self._setup_data() @@ -140,7 +140,7 @@ class EmbedartCliTest(PluginMixin, FetchImageHelper, BeetsTestCase): os.remove(syspath(tmp_path)) mediafile = MediaFile(syspath(album.items()[0].path)) - self.assertFalse(mediafile.images) # No image added. + assert not mediafile.images # No image added. @require_artresizer_compare def test_reject_different_art(self): @@ -209,7 +209,7 @@ class EmbedartCliTest(PluginMixin, FetchImageHelper, BeetsTestCase): self.io.addinput("y") self.run_command("clearart") mediafile = MediaFile(syspath(item.path)) - self.assertFalse(mediafile.images) + assert not mediafile.images def test_clear_art_with_no_input(self): self._setup_data() @@ -254,7 +254,7 @@ class EmbedartCliTest(PluginMixin, FetchImageHelper, BeetsTestCase): self.mock_response("http://example.com/test.html", "text/html") self.run_command("embedart", "-y", "-u", "http://example.com/test.html") mediafile = MediaFile(syspath(item.path)) - self.assertFalse(mediafile.images) + assert not mediafile.images class DummyArtResizer(ArtResizer): @@ -312,7 +312,7 @@ class ArtSimilarityTest(unittest.TestCase): def test_compare_success_different(self, mock_extract, mock_subprocess): self._mock_popens(mock_extract, mock_subprocess, 0, "10", "err") - self.assertFalse(self._similarity(5)) + assert not self._similarity(5) def test_compare_status1_similar(self, mock_extract, mock_subprocess): self._mock_popens(mock_extract, mock_subprocess, 1, "out", "10") @@ -320,7 +320,7 @@ class ArtSimilarityTest(unittest.TestCase): def test_compare_status1_different(self, mock_extract, mock_subprocess): self._mock_popens(mock_extract, mock_subprocess, 1, "out", "10") - self.assertFalse(self._similarity(5)) + assert not self._similarity(5) def test_compare_failed(self, mock_extract, mock_subprocess): self._mock_popens(mock_extract, mock_subprocess, 2, "out", "10") diff --git a/test/plugins/test_ftintitle.py b/test/plugins/test_ftintitle.py index a0cd679e7..e98bd92c1 100644 --- a/test/plugins/test_ftintitle.py +++ b/test/plugins/test_ftintitle.py @@ -167,5 +167,5 @@ class FtInTitlePluginTest(unittest.TestCase): assert ftintitle.contains_feat("Alice & Bob") assert ftintitle.contains_feat("Alice and Bob") assert ftintitle.contains_feat("Alice With Bob") - self.assertFalse(ftintitle.contains_feat("Alice defeat Bob")) - self.assertFalse(ftintitle.contains_feat("Aliceft.Bob")) + assert not ftintitle.contains_feat("Alice defeat Bob") + assert not ftintitle.contains_feat("Aliceft.Bob") diff --git a/test/plugins/test_ihate.py b/test/plugins/test_ihate.py index 66e73a725..f941d566c 100644 --- a/test/plugins/test_ihate.py +++ b/test/plugins/test_ihate.py @@ -16,7 +16,7 @@ class IHatePluginTest(unittest.TestCase): task = importer.SingletonImportTask(None, test_item) # Empty query should let it pass. - self.assertFalse(IHatePlugin.do_i_hate_this(task, match_pattern)) + assert not IHatePlugin.do_i_hate_this(task, match_pattern) # 1 query match. match_pattern = ["artist:bad_artist", "artist:TestArtist"] @@ -28,14 +28,14 @@ class IHatePluginTest(unittest.TestCase): # Query is blocked by AND clause. match_pattern = ["album:notthis genre:testgenre"] - self.assertFalse(IHatePlugin.do_i_hate_this(task, match_pattern)) + assert not IHatePlugin.do_i_hate_this(task, match_pattern) # Both queries are blocked by AND clause with unmatched condition. match_pattern = [ "album:notthis genre:testgenre", "artist:testartist album:notthis", ] - self.assertFalse(IHatePlugin.do_i_hate_this(task, match_pattern)) + assert not IHatePlugin.do_i_hate_this(task, match_pattern) # Only one query should fire. match_pattern = [ diff --git a/test/plugins/test_lyrics.py b/test/plugins/test_lyrics.py index cecfd88eb..ef2c2f44f 100644 --- a/test/plugins/test_lyrics.py +++ b/test/plugins/test_lyrics.py @@ -163,7 +163,7 @@ class LyricsPluginTest(unittest.TestCase): of mywickedsongtext brand""" ] for t in texts: - self.assertFalse(google.is_lyrics(t)) + assert not google.is_lyrics(t) def test_slugify(self): text = "http://site.com/\xe7afe-au_lait(boisson)" @@ -195,7 +195,7 @@ class LyricsPluginTest(unittest.TestCase): ) def test_missing_lyrics(self): - self.assertFalse(google.is_lyrics(LYRICS_TEXTS["missing_texts"])) + assert not google.is_lyrics(LYRICS_TEXTS["missing_texts"]) def url_to_filename(url): @@ -437,10 +437,9 @@ class LyricsGooglePluginMachineryTest(LyricsGoogleBaseTest, LyricsAssertions): ), url # reject different title url_title = "example.com | seets bong lyrics by John doe" - self.assertFalse( - google.is_page_candidate(url, url_title, s["title"], s["artist"]), - url, - ) + assert not google.is_page_candidate( + url, url_title, s["title"], s["artist"] + ), url def test_is_page_candidate_special_chars(self): """Ensure that `is_page_candidate` doesn't crash when the artist diff --git a/test/plugins/test_mpdstats.py b/test/plugins/test_mpdstats.py index 325fd5cd3..91dc253ce 100644 --- a/test/plugins/test_mpdstats.py +++ b/test/plugins/test_mpdstats.py @@ -31,8 +31,8 @@ class MPDStatsTest(PluginTestCase): log = Mock() mpdstats = MPDStats(self.lib, log) - self.assertFalse(mpdstats.update_rating(item, True)) - self.assertFalse(mpdstats.update_rating(None, True)) + assert not mpdstats.update_rating(item, True) + assert not mpdstats.update_rating(None, True) def test_get_item(self): item_path = util.normpath("/foo/bar.flac") diff --git a/test/plugins/test_player.py b/test/plugins/test_player.py index 512c89f1b..bc1e9a1f3 100644 --- a/test/plugins/test_player.py +++ b/test/plugins/test_player.py @@ -388,7 +388,7 @@ class BPDTestHelper(PluginTestCase): previous_commands = response[0:pos] self._assert_ok(*previous_commands) response = response[pos] - self.assertFalse(response.ok) + assert not response.ok if pos is not None: self.assertEqual(pos, response.err_data[1]) if code is not None: diff --git a/test/plugins/test_smartplaylist.py b/test/plugins/test_smartplaylist.py index da51ba789..a60461c16 100644 --- a/test/plugins/test_smartplaylist.py +++ b/test/plugins/test_smartplaylist.py @@ -109,17 +109,17 @@ class SmartPlaylistTest(BeetsTestCase): a = MagicMock(Album) i = MagicMock(Item) - self.assertFalse(spl.matches(i, None, None)) - self.assertFalse(spl.matches(a, None, None)) + assert not spl.matches(i, None, None) + assert not spl.matches(a, None, None) query = Mock() query.match.side_effect = {i: True}.__getitem__ assert spl.matches(i, query, None) - self.assertFalse(spl.matches(a, query, None)) + assert not spl.matches(a, query, None) a_query = Mock() a_query.match.side_effect = {a: True}.__getitem__ - self.assertFalse(spl.matches(i, None, a_query)) + assert not spl.matches(i, None, a_query) assert spl.matches(a, None, a_query) assert spl.matches(i, query, a_query) diff --git a/test/plugins/test_spotify.py b/test/plugins/test_spotify.py index 3aed50edb..646c748da 100644 --- a/test/plugins/test_spotify.py +++ b/test/plugins/test_spotify.py @@ -45,7 +45,7 @@ class SpotifyPluginTest(BeetsTestCase): def test_args(self): opts = ArgumentsMock("fail", True) - self.assertFalse(self.spotify._parse_opts(opts)) + assert not self.spotify._parse_opts(opts) opts = ArgumentsMock("list", False) assert self.spotify._parse_opts(opts) diff --git a/test/plugins/test_thumbnails.py b/test/plugins/test_thumbnails.py index 8f1c44d55..8b61816be 100644 --- a/test/plugins/test_thumbnails.py +++ b/test/plugins/test_thumbnails.py @@ -58,7 +58,7 @@ class ThumbnailsTest(BeetsTestCase): mock_artresizer.shared.local = False mock_artresizer.shared.can_write_metadata = False plugin = ThumbnailsPlugin() - self.assertFalse(plugin._check_local_ok()) + assert not plugin._check_local_ok() # test dirs creation mock_artresizer.shared.local = True diff --git a/test/plugins/test_types_plugin.py b/test/plugins/test_types_plugin.py index 91aefa08d..3f6bb5b70 100644 --- a/test/plugins/test_types_plugin.py +++ b/test/plugins/test_types_plugin.py @@ -90,7 +90,7 @@ class TypesPluginTest(PluginTestCase): # Set false self.modify("mybool=false", "artist:false") false.load() - self.assertFalse(false["mybool"]) + assert not false["mybool"] # Query bools out = self.list("mybool:true", "$artist $mybool") diff --git a/test/plugins/test_web.py b/test/plugins/test_web.py index 71574ca88..1da223bf1 100644 --- a/test/plugins/test_web.py +++ b/test/plugins/test_web.py @@ -378,7 +378,7 @@ class WebPluginTest(ItemInDBTestCase): self.assertEqual(response.status_code, 404) # Check the file has gone - self.assertFalse(os.path.exists(ipath)) + assert not os.path.exists(ipath) def test_delete_item_query(self): web.app.config["READONLY"] = False diff --git a/test/plugins/test_zero.py b/test/plugins/test_zero.py index c267c0708..9238c4783 100644 --- a/test/plugins/test_zero.py +++ b/test/plugins/test_zero.py @@ -82,7 +82,7 @@ class ZeroPluginTest(PluginTestCase): item.write() mf = MediaFile(syspath(path)) - self.assertFalse(mf.images) + assert not mf.images def test_auto_false(self): item = self.add_item_fixture(year=2000) diff --git a/test/test_autotag.py b/test/test_autotag.py index fe19b2885..6928f42e2 100644 --- a/test/test_autotag.py +++ b/test/test_autotag.py @@ -58,7 +58,7 @@ class PluralityTest(BeetsTestCase): likelies, consensus = match.current_metadata(items) self.assertEqual(likelies["artist"], "The Beatles") self.assertEqual(likelies["album"], "The White Album") - self.assertFalse(consensus["artist"]) + assert not consensus["artist"] def test_current_metadata_artist_consensus(self): items = [ @@ -79,7 +79,7 @@ class PluralityTest(BeetsTestCase): ] likelies, consensus = match.current_metadata(items) self.assertEqual(likelies["artist"], "aartist") - self.assertFalse(consensus["artist"]) + assert not consensus["artist"] def test_current_metadata_likelies(self): fields = [ @@ -986,8 +986,8 @@ class ApplyCompilationTest(BeetsTestCase, ApplyTestUtil): def test_va_flag_cleared_does_not_set_comp(self): self._apply() - self.assertFalse(self.items[0].comp) - self.assertFalse(self.items[1].comp) + assert not self.items[0].comp + assert not self.items[1].comp def test_va_flag_sets_comp(self): va_info = self.info.copy() diff --git a/test/test_config_command.py b/test/test_config_command.py index 980ef93a2..6f94bf872 100644 --- a/test/test_config_command.py +++ b/test/test_config_command.py @@ -46,7 +46,7 @@ class ConfigCommandTest(BeetsTestCase): self.assertEqual(output["option"], "value") self.assertEqual(output["password"], "password_value") self.assertEqual(output["library"], "lib") - self.assertFalse(output["import"]["timid"]) + assert not output["import"]["timid"] def test_show_user_config_with_cli(self): output = self._run_with_yaml_output( @@ -67,7 +67,7 @@ class ConfigCommandTest(BeetsTestCase): self.assertEqual(output["option"], "value") self.assertEqual(output["password"], "REDACTED") - self.assertFalse(output["import"]["timid"]) + assert not output["import"]["timid"] def test_config_paths(self): output = self.run_with_output("config", "-p") diff --git a/test/test_datequery.py b/test/test_datequery.py index 284889f8e..4eb44cd7f 100644 --- a/test/test_datequery.py +++ b/test/test_datequery.py @@ -145,7 +145,7 @@ class DateIntervalTest(unittest.TestCase): date = _date(date_pattern) (start, end) = _parse_periods(interval_pattern) interval = DateInterval.from_periods(start, end) - self.assertFalse(interval.contains(date)) + assert not interval.contains(date) def _parsetime(s): @@ -174,7 +174,7 @@ class DateQueryTest(ItemInDBTestCase): def test_single_month_nonmatch_slow(self): query = DateQuery("added", "2013-04") - self.assertFalse(query.match(self.i)) + assert not query.match(self.i) def test_single_day_match_fast(self): query = DateQuery("added", "2013-03-30") @@ -218,7 +218,7 @@ class DateQueryTestRelative(ItemInDBTestCase): query = DateQuery( "added", (self._now + timedelta(days=30)).strftime("%Y-%m") ) - self.assertFalse(query.match(self.i)) + assert not query.match(self.i) def test_single_day_match_fast(self): query = DateQuery("added", self._now.strftime("%Y-%m-%d")) diff --git a/test/test_importer.py b/test/test_importer.py index 7e3cefad5..97aa2e73a 100644 --- a/test/test_importer.py +++ b/test/test_importer.py @@ -1027,7 +1027,7 @@ class InferAlbumDataTest(BeetsTestCase): def test_asis_homogenous_single_artist(self): self.task.set_choice(importer.action.ASIS) self.task.align_album_level_fields() - self.assertFalse(self.items[0].comp) + assert not self.items[0].comp self.assertEqual(self.items[0].albumartist, self.items[2].artist) def test_asis_heterogenous_va(self): @@ -1057,7 +1057,7 @@ class InferAlbumDataTest(BeetsTestCase): self.task.align_album_level_fields() - self.assertFalse(self.items[0].comp) + assert not self.items[0].comp self.assertEqual(self.items[0].albumartist, self.items[2].artist) def test_asis_track_albumartist_override(self): @@ -1099,7 +1099,7 @@ class InferAlbumDataTest(BeetsTestCase): self.task.items = self.items self.task.set_choice(importer.action.ASIS) self.task.align_album_level_fields() - self.assertFalse(self.items[0].comp) + assert not self.items[0].comp def match_album_mock(*args, **kwargs): diff --git a/test/test_logging.py b/test/test_logging.py index 0a1267587..0c84bbe73 100644 --- a/test/test_logging.py +++ b/test/test_logging.py @@ -232,7 +232,7 @@ class ConcurrentEventsTest(AsIsImporterMixin, ImportTestCase): while dp.t1_step != 2: check_dp_exc() t1.join(0.1) - self.assertFalse(t1.is_alive()) + assert not t1.is_alive() assert t2.is_alive() self.assertEqual(dp._log.level, log.NOTSET) @@ -240,7 +240,7 @@ class ConcurrentEventsTest(AsIsImporterMixin, ImportTestCase): while dp.t2_step != 2: check_dp_exc() t2.join(0.1) - self.assertFalse(t2.is_alive()) + assert not t2.is_alive() except Exception: print("Alive threads:", threading.enumerate()) diff --git a/test/test_m3ufile.py b/test/test_m3ufile.py index 36631bb9f..44c362792 100644 --- a/test/test_m3ufile.py +++ b/test/test_m3ufile.py @@ -147,4 +147,4 @@ class M3UFileTest(unittest.TestCase): the_playlist_file = path.join(RSRC, b"playlist_non_ext.m3u") m3ufile = M3UFile(the_playlist_file) m3ufile.load() - self.assertFalse(m3ufile.extm3u) + assert not m3ufile.extm3u diff --git a/test/test_mb.py b/test/test_mb.py index d95360f0e..abe35f520 100644 --- a/test/test_mb.py +++ b/test/test_mb.py @@ -329,14 +329,14 @@ class MBAlbumInfoTest(BeetsTestCase): def test_no_release_date(self): release = self._make_release(None) d = mb.album_info(release) - self.assertFalse(d.original_year) - self.assertFalse(d.original_month) - self.assertFalse(d.original_day) + assert not d.original_year + assert not d.original_month + assert not d.original_day def test_various_artists_defaults_false(self): release = self._make_release(None) d = mb.album_info(release) - self.assertFalse(d.va) + assert not d.va def test_detect_various_artists(self): release = self._make_release(None) @@ -842,13 +842,13 @@ class MBLibraryTest(unittest.TestCase): def test_match_track_empty(self): with mock.patch("musicbrainzngs.search_recordings") as p: til = list(mb.match_track(" ", " ")) - self.assertFalse(p.called) + assert not p.called self.assertEqual(til, []) def test_match_album_empty(self): with mock.patch("musicbrainzngs.search_releases") as p: ail = list(mb.match_album(" ", " ")) - self.assertFalse(p.called) + assert not p.called self.assertEqual(ail, []) def test_follow_pseudo_releases(self): diff --git a/test/test_metasync.py b/test/test_metasync.py index 4b97bf7d8..f3b9c4912 100644 --- a/test/test_metasync.py +++ b/test/test_metasync.py @@ -105,7 +105,7 @@ class MetaSyncTest(PluginTestCase): self.assertEqual(self.lib.items()[0].itunes_rating, 80) self.assertEqual(self.lib.items()[0].itunes_playcount, 0) self.assertEqual(self.lib.items()[0].itunes_skipcount, 3) - self.assertFalse(hasattr(self.lib.items()[0], "itunes_lastplayed")) + assert not hasattr(self.lib.items()[0], "itunes_lastplayed") self.assertEqual( self.lib.items()[0].itunes_lastskipped, _parsetime("2015-02-05 15:41:04"), @@ -126,4 +126,4 @@ class MetaSyncTest(PluginTestCase): self.lib.items()[1].itunes_dateadded, _parsetime("2014-04-24 09:28:38"), ) - self.assertFalse(hasattr(self.lib.items()[1], "itunes_lastskipped")) + assert not hasattr(self.lib.items()[1], "itunes_lastskipped") diff --git a/test/test_plugins.py b/test/test_plugins.py index 709727d0a..2dd216337 100644 --- a/test/test_plugins.py +++ b/test/test_plugins.py @@ -298,7 +298,6 @@ class ListenersTest(PluginLoaderTestCase): @patch("beets.plugins.find_plugins") def test_listener_params(self, mock_find_plugins): - test = self class DummyPlugin(plugins.BeetsPlugin): def __init__(self): @@ -325,7 +324,7 @@ class ListenersTest(PluginLoaderTestCase): pass def dummy5(self, bar): - test.assertFalse(True) + assert not True # more complex examples @@ -338,7 +337,7 @@ class ListenersTest(PluginLoaderTestCase): test.assertEqual(kwargs, {}) def dummy8(self, foo, bar, **kwargs): - test.assertFalse(True) + assert not True def dummy9(self, **kwargs): test.assertEqual(kwargs, {"foo": 5}) diff --git a/test/test_query.py b/test/test_query.py index b8fc45025..63cd04a70 100644 --- a/test/test_query.py +++ b/test/test_query.py @@ -387,7 +387,7 @@ class GetTest(DummyDataTestCase): def test_numeric_search_negative(self): q = dbcore.query.NumericQuery("year", "1999") results = self.lib.items(q) - self.assertFalse(results) + assert not results def test_album_field_fallback(self): self.album["albumflex"] = "foo" @@ -427,7 +427,7 @@ class MatchTest(BeetsTestCase): def test_regex_match_negative(self): q = dbcore.query.RegexpQuery("album", "^album$") - self.assertFalse(q.match(self.item)) + assert not q.match(self.item) def test_regex_match_non_string_value(self): q = dbcore.query.RegexpQuery("disc", "^6$") @@ -439,7 +439,7 @@ class MatchTest(BeetsTestCase): def test_substring_match_negative(self): q = dbcore.query.SubstringQuery("album", "ablum") - self.assertFalse(q.match(self.item)) + assert not q.match(self.item) def test_substring_match_non_string_value(self): q = dbcore.query.SubstringQuery("disc", "6") @@ -453,7 +453,7 @@ class MatchTest(BeetsTestCase): def test_exact_match_nocase_negative(self): q = dbcore.query.StringQuery("genre", "genre") - self.assertFalse(q.match(self.item)) + assert not q.match(self.item) def test_year_match_positive(self): q = dbcore.query.NumericQuery("year", "1") @@ -461,7 +461,7 @@ class MatchTest(BeetsTestCase): def test_year_match_negative(self): q = dbcore.query.NumericQuery("year", "10") - self.assertFalse(q.match(self.item)) + assert not q.match(self.item) def test_bitrate_range_positive(self): q = dbcore.query.NumericQuery("bitrate", "100000..200000") @@ -469,7 +469,7 @@ class MatchTest(BeetsTestCase): def test_bitrate_range_negative(self): q = dbcore.query.NumericQuery("bitrate", "200000..300000") - self.assertFalse(q.match(self.item)) + assert not q.match(self.item) def test_open_range(self): dbcore.query.NumericQuery("bitrate", "100000..") @@ -698,7 +698,7 @@ class PathQueryTest(ItemInDBTestCase, AssertsMixin): assert is_path_query(parent) # Some non-existent path. - self.assertFalse(is_path_query(path_str + "baz")) + assert not is_path_query(path_str + "baz") def test_detect_relative_path(self): """Test detection of implicit path queries based on whether or diff --git a/test/test_ui.py b/test/test_ui.py index 0bec10118..e847b0cda 100644 --- a/test/test_ui.py +++ b/test/test_ui.py @@ -598,14 +598,14 @@ class UpdateTest(BeetsTestCase): util.remove(self.i.path) util.remove(self.i2.path) self._update() - self.assertFalse(list(self.lib.items())) + assert not list(self.lib.items()) def test_delete_removes_album(self): assert self.lib.albums() util.remove(self.i.path) util.remove(self.i2.path) self._update() - self.assertFalse(self.lib.albums()) + assert not self.lib.albums() def test_delete_removes_album_art(self): artpath = self.album.artpath @@ -1096,7 +1096,7 @@ class ConfigTest(TestPluginTestCase): file.write("anoption: value") config.read() - self.assertFalse(config["anoption"].exists()) + assert not config["anoption"].exists() def test_default_config_paths_resolve_relative_to_beetsdir(self): os.environ["BEETSDIR"] = os.fsdecode(self.beetsdir) @@ -1145,7 +1145,7 @@ class ShowModelChangeTest(BeetsTestCase): def test_identical(self): change, out = self._show() - self.assertFalse(change) + assert not change self.assertEqual(out, "") def test_string_fixed_field_change(self): @@ -1164,7 +1164,7 @@ class ShowModelChangeTest(BeetsTestCase): self.a.length = 1.00001 self.b.length = 1.00005 change, out = self._show() - self.assertFalse(change) + assert not change self.assertEqual(out, "") def test_floats_different(self): @@ -1440,10 +1440,10 @@ class CompletionTest(TestPluginTestCase): with open(test_script_name, "rb") as test_script_file: tester.stdin.writelines(test_script_file) out, err = tester.communicate() - self.assertFalse( - tester.returncode != 0 or out != b"completion tests passed\n", - f"test/test_completion.sh did not execute properly. " - f'Output:{out.decode("utf-8")}', + assert tester.returncode == 0 + assert out == b"completion tests passed\n", ( + "test/test_completion.sh did not execute properly. " + f'Output:{out.decode("utf-8")}' ) @@ -1528,7 +1528,7 @@ class CommonOptionsParserCliTest(BeetsTestCase): class CommonOptionsParserTest(BeetsTestCase): def test_album_option(self): parser = ui.CommonOptionsParser() - self.assertFalse(parser._album_flags) + assert not parser._album_flags parser.add_album_option() assert bool(parser._album_flags) @@ -1539,7 +1539,7 @@ class CommonOptionsParserTest(BeetsTestCase): def test_path_option(self): parser = ui.CommonOptionsParser() parser.add_path_option() - self.assertFalse(parser._album_flags) + assert not parser._album_flags config["format_item"].set("$foo") self.assertEqual(parser.parse_args([]), ({"path": None}, [])) @@ -1559,7 +1559,7 @@ class CommonOptionsParserTest(BeetsTestCase): def test_format_option(self): parser = ui.CommonOptionsParser() parser.add_format_option() - self.assertFalse(parser._album_flags) + assert not parser._album_flags config["format_item"].set("$foo") self.assertEqual(parser.parse_args([]), ({"format": None}, []))