Remove obsolete null checks

Along with their tests. Background:
https://github.com/sampsyo/beets/pull/720/files#r12027386
This commit is contained in:
Adrian Sampson 2014-04-26 20:07:26 -07:00
parent 1d787e0b38
commit 38eba4af31
2 changed files with 5 additions and 22 deletions

View file

@ -487,24 +487,14 @@ class ImportTask(object):
elif self.choice_flag == action.APPLY:
# Applying autotagged metadata. Just get AA from the first
# item.
# FIXME this is overly complicated. Can we assume that
# `self.items` contains only elements that are not none and
# at least one of them?
for item in self.items:
if item is not None:
first_item = item
break
else:
assert False, "all items are None"
if not first_item.albumartist:
changes['albumartist'] = first_item.artist
if not first_item.mb_albumartistid:
changes['mb_albumartistid'] = first_item.mb_artistid
if not self.items[0].albumartist:
changes['albumartist'] = self.items[0].artist
if not self.items[0].mb_albumartistid:
changes['mb_albumartistid'] = self.items[0].mb_artistid
# Apply new metadata.
for item in self.items:
if item is not None:
item.update(changes)
item.update(changes)
def manipulate_files(self, move=False, copy=False, write=False,
session=None):

View file

@ -947,13 +947,6 @@ class InferAlbumDataTest(_common.TestCase):
self.task.infer_album_fields()
self.assertFalse(self.items[0].comp)
def test_first_item_null_apply(self):
self.items[0] = None
self.task.set_choice(AlbumMatch(0, None, {}, set(), set())) # APPLY
self.task.infer_album_fields()
self.assertFalse(self.items[1].comp)
self.assertEqual(self.items[1].albumartist, self.items[2].artist)
class ImportDuplicateAlbumTest(unittest.TestCase, TestHelper):