Replace assertNotEqual

This commit is contained in:
Šarūnas Nejus 2024-08-05 17:44:06 +01:00
parent 847e3858a6
commit f9359df0d1
No known key found for this signature in database
GPG key ID: DD28F6704DBE3435
11 changed files with 40 additions and 46 deletions

View file

@ -869,7 +869,7 @@ class ArtForAlbumTest(UseThePlugin):
candidate = self.plugin.art_for_album(self.album, [""], True)
if should_exist:
self.assertNotEqual(candidate, None)
assert candidate is not None
assert candidate.path == self.image_file
self.assertExists(candidate.path)
else:

View file

@ -77,12 +77,8 @@ class ConvertMixin:
self.assertIsFile(path)
with open(path, "rb") as f:
f.seek(-len(tag), os.SEEK_END)
self.assertNotEqual(
f.read(),
tag,
"{} is unexpectedly tagged with {}".format(
displayable_path(path), display_tag
),
assert f.read() != tag, "{} is unexpectedly tagged with {}".format(
displayable_path(path), display_tag
)

View file

@ -124,7 +124,7 @@ class LastGenrePluginTest(BeetsTestCase):
tree still has to be loaded.
"""
self._setup_config(prefer_specific=True, canonical=False)
self.assertNotEqual(self.plugin.c14n_branches, [])
assert self.plugin.c14n_branches != []
def test_prefer_specific_without_canonical(self):
"""Prefer_specific works without canonical."""

View file

@ -256,8 +256,8 @@ class ReplayGainCliTest:
assert max(peaks) == min(peaks)
assert max(gains) == min(gains)
self.assertNotEqual(max(gains), 0.0)
self.assertNotEqual(max(peaks), 0.0)
assert max(gains) != 0.0
assert max(peaks) != 0.0
def test_cli_writes_only_r128_tags(self):
if not self.has_r128_support:
@ -293,7 +293,7 @@ class ReplayGainCliTest:
gain_relative_to_84 = analyse(84)
gain_relative_to_89 = analyse(89)
self.assertNotEqual(gain_relative_to_84, gain_relative_to_89)
assert gain_relative_to_84 != gain_relative_to_89
def test_r128_targetlevel_has_effect(self):
if not self.has_r128_support:
@ -315,7 +315,7 @@ class ReplayGainCliTest:
gain_relative_to_84 = analyse(84)
gain_relative_to_89 = analyse(89)
self.assertNotEqual(gain_relative_to_84, gain_relative_to_89)
assert gain_relative_to_84 != gain_relative_to_89
def test_per_disc(self):
# Use the per_disc option and add a little more concurrency.

View file

@ -228,7 +228,7 @@ class DistanceTest(BeetsTestCase):
sdist = string_dist("abc", "bcd")
dist.add_string("string", "abc", "bcd")
assert dist._penalties["string"] == [sdist]
self.assertNotEqual(dist._penalties["string"], [0])
assert dist._penalties["string"] != [0]
def test_add_string_none(self):
dist = Distance()
@ -342,14 +342,14 @@ class TrackDistanceTest(BeetsTestCase):
item = _make_item("foo", 1)
info = _make_trackinfo()[0]
dist = match.track_distance(item, info, incl_artist=True)
self.assertNotEqual(dist, 0.0)
assert dist != 0.0
def test_different_artist(self):
item = _make_item("one", 1)
item.artist = "foo"
info = _make_trackinfo()[0]
dist = match.track_distance(item, info, incl_artist=True)
self.assertNotEqual(dist, 0.0)
assert dist != 0.0
def test_various_artists_tolerated(self):
item = _make_item("one", 1)
@ -393,7 +393,7 @@ class AlbumDistanceTest(BeetsTestCase):
va=False,
)
dist = self._dist(items, info)
self.assertNotEqual(dist, 0)
assert dist != 0
# Make sure the distance is not too great
self.assertLess(dist, 0.2)
@ -408,7 +408,7 @@ class AlbumDistanceTest(BeetsTestCase):
tracks=_make_trackinfo(),
va=False,
)
self.assertNotEqual(self._dist(items, info), 0)
assert self._dist(items, info) != 0
def test_comp_track_artists_match(self):
items = []
@ -451,7 +451,7 @@ class AlbumDistanceTest(BeetsTestCase):
tracks=_make_trackinfo(),
va=True,
)
self.assertNotEqual(self._dist(items, info), 0)
assert self._dist(items, info) != 0
def test_tracks_out_of_order(self):
items = []
@ -977,7 +977,7 @@ class StringDistanceTest(unittest.TestCase):
def test_different_strings(self):
dist = string_dist("Some String", "Totally Different")
self.assertNotEqual(dist, 0.0)
assert dist != 0.0
def test_punctuation_ignored(self):
dist = string_dist("Some String", "Some.String!")

View file

@ -352,7 +352,7 @@ class ModelTest(unittest.TestCase):
model.some_boolean_field = True
for field, type_ in model._fields.items():
self.assertNotEqual(model[field], type_.null)
assert model[field] != type_.null
for field, type_ in model._fields.items():
del model[field]

View file

@ -161,7 +161,7 @@ class MoveTest(BeetsTestCase):
touch(dest)
self.i.move()
self.assertNotEqual(self.i.path, dest)
assert self.i.path != dest
assert os.path.dirname(self.i.path) == os.path.dirname(dest)
@unittest.skipUnless(_common.HAVE_SYMLINK, "need symlinks")
@ -336,7 +336,7 @@ class ArtFileTest(BeetsTestCase):
self.ai.move()
self.i.load()
self.assertNotEqual(self.i.path, oldpath)
assert self.i.path != oldpath
self.assertNotExists(self.art)
newart = self.lib.get_album(self.i).art_destination(self.art)
self.assertExists(newart)
@ -417,7 +417,7 @@ class ArtFileTest(BeetsTestCase):
# Set the art.
ai.set_art(newart)
self.assertNotEqual(artdest, ai.artpath)
assert artdest != ai.artpath
assert os.path.dirname(artdest) == os.path.dirname(ai.artpath)
def test_setart_sets_permissions(self):

View file

@ -563,7 +563,7 @@ class ItemFormattedMappingTest(ItemInDBTestCase):
album = self.lib.add_album([self.i])
album["artist"] = "foo"
album.store()
self.assertNotEqual("foo", self.i.formatted().get("artist"))
assert "foo" != self.i.formatted().get("artist")
def test_album_flex_field(self):
album = self.lib.add_album([self.i])
@ -997,7 +997,7 @@ class AlbumInfoTest(BeetsTestCase):
ai.store()
i = self.lib.items()[0]
assert i.albumartist == "myNewArtist"
self.assertNotEqual(i.artist, "myNewArtist")
assert i.artist != "myNewArtist"
def test_albuminfo_change_artist_does_change_items(self):
ai = self.lib.get_album(self.i)
@ -1011,7 +1011,7 @@ class AlbumInfoTest(BeetsTestCase):
ai.artist = "myNewArtist"
ai.store(inherit=False)
i = self.lib.items()[0]
self.assertNotEqual(i.artist, "myNewArtist")
assert i.artist != "myNewArtist"
def test_albuminfo_remove_removes_items(self):
item_id = self.i.id
@ -1262,19 +1262,17 @@ class WriteTest(BeetsTestCase):
shutil.copy(syspath(item.path), syspath(custom_path))
item["artist"] = "new artist"
self.assertNotEqual(
MediaFile(syspath(custom_path)).artist, "new artist"
)
self.assertNotEqual(MediaFile(syspath(item.path)).artist, "new artist")
assert MediaFile(syspath(custom_path)).artist != "new artist"
assert MediaFile(syspath(item.path)).artist != "new artist"
item.write(custom_path)
assert MediaFile(syspath(custom_path)).artist == "new artist"
self.assertNotEqual(MediaFile(syspath(item.path)).artist, "new artist")
assert MediaFile(syspath(item.path)).artist != "new artist"
def test_write_custom_tags(self):
item = self.add_item_fixture(artist="old artist")
item.write(tags={"artist": "new artist"})
self.assertNotEqual(item.artist, "new artist")
assert item.artist != "new artist"
assert MediaFile(syspath(item.path)).artist == "new artist"
def test_write_multi_tags(self):
@ -1322,7 +1320,7 @@ class ItemReadTest(unittest.TestCase):
class FilesizeTest(BeetsTestCase):
def test_filesize(self):
item = self.add_item_fixture()
self.assertNotEqual(item.filesize, 0)
assert item.filesize != 0
def test_nonexistent_file(self):
item = beets.library.Item()

View file

@ -36,7 +36,7 @@ class LoggingTest(BeetsTestCase):
assert l5.__class__ == blog.BeetsLogger
l6 = blog.getLogger()
self.assertNotEqual(l1, l6)
assert l1 != l6
def test_str_format_logging(self):
l = blog.getLogger("baz123")

View file

@ -88,7 +88,7 @@ class AnyFieldQueryTest(ItemInDBTestCase):
assert q1 == q2
q2.query_class = None
self.assertNotEqual(q1, q2)
assert q1 != q2
# A test case class providing a library with some dummy data and some
@ -472,9 +472,9 @@ class MatchTest(BeetsTestCase):
q3 = dbcore.query.MatchQuery("foo", "baz")
q4 = dbcore.query.StringFieldQuery("foo", "bar")
assert q1 == q2
self.assertNotEqual(q1, q3)
self.assertNotEqual(q1, q4)
self.assertNotEqual(q3, q4)
assert q1 != q3
assert q1 != q4
assert q3 != q4
class PathQueryTest(ItemInDBTestCase, AssertsMixin):

View file

@ -229,7 +229,7 @@ class ModifyTest(BeetsTestCase):
self.modify("--nowrite", "title=newTitle")
item = self.lib.items().get()
item.read()
self.assertNotEqual(item.title, "newTitle")
assert item.title != "newTitle"
def test_move(self):
self.modify("title=newTitle")
@ -246,7 +246,7 @@ class ModifyTest(BeetsTestCase):
item = self.lib.items().get()
item.read()
assert b"newTitle" not in item.path
self.assertNotEqual(item.title, "newTitle")
assert item.title != "newTitle"
def test_update_mtime(self):
item = self.item
@ -254,7 +254,7 @@ class ModifyTest(BeetsTestCase):
self.modify("title=newTitle")
item.load()
self.assertNotEqual(old_mtime, item.mtime)
assert old_mtime != item.mtime
assert item.current_mtime() == item.mtime
def test_reset_mtime_with_no_write(self):
@ -646,7 +646,7 @@ class UpdateTest(BeetsTestCase):
self._update(move=True, fields=["title"])
item = self.lib.items().get()
assert b"differentTitle" in item.path
self.assertNotEqual(item.genre, "differentGenre")
assert item.genre != "differentGenre"
def test_selective_modified_metadata_not_moved(self):
mf = MediaFile(syspath(self.i.path))
@ -656,7 +656,7 @@ class UpdateTest(BeetsTestCase):
self._update(move=False, fields=["title"])
item = self.lib.items().get()
assert b"differentTitle" not in item.path
self.assertNotEqual(item.genre, "differentGenre")
assert item.genre != "differentGenre"
def test_modified_album_metadata_moved(self):
mf = MediaFile(syspath(self.i.path))
@ -673,7 +673,7 @@ class UpdateTest(BeetsTestCase):
mf.save()
self._update(move=True)
album = self.lib.albums()[0]
self.assertNotEqual(artpath, album.artpath)
assert artpath != album.artpath
assert album.artpath is not None
def test_selective_modified_album_metadata_moved(self):
@ -684,7 +684,7 @@ class UpdateTest(BeetsTestCase):
self._update(move=True, fields=["album"])
item = self.lib.items().get()
assert b"differentAlbum" in item.path
self.assertNotEqual(item.genre, "differentGenre")
assert item.genre != "differentGenre"
def test_selective_modified_album_metadata_not_moved(self):
mf = MediaFile(syspath(self.i.path))
@ -740,7 +740,7 @@ class UpdateTest(BeetsTestCase):
mf.save()
self._update(exclude_fields=["lyrics"])
item = self.lib.items().get()
self.assertNotEqual(item.lyrics, "new lyrics")
assert item.lyrics != "new lyrics"
class PrintTest(BeetsTestCase):