mirror of
https://github.com/beetbox/beets.git
synced 2025-12-29 03:52:51 +01:00
fix failure mode of order_items for length mismatch
This commit is contained in:
parent
2a91ddf40b
commit
45870e6639
2 changed files with 13 additions and 0 deletions
|
|
@ -203,6 +203,10 @@ def order_items(items, trackinfo):
|
|||
information. This always produces a result if the numbers of tracks
|
||||
match.
|
||||
"""
|
||||
# Make sure lengths match.
|
||||
if len(items) != len(trackinfo):
|
||||
return None
|
||||
|
||||
# Construct the cost matrix.
|
||||
costs = []
|
||||
for cur_item in items:
|
||||
|
|
|
|||
|
|
@ -111,6 +111,15 @@ class OrderingTest(unittest.TestCase):
|
|||
self.assertEqual(ordered[1].title, 'two')
|
||||
self.assertEqual(ordered[2].title, 'three')
|
||||
|
||||
def test_order_returns_none_for_length_mismatch(self):
|
||||
items = []
|
||||
items.append(self.item('one', 1))
|
||||
items.append(self.item('two', 2))
|
||||
trackinfo = []
|
||||
trackinfo.append({'title': 'one', 'track': 1})
|
||||
ordered = autotag.order_items(items, trackinfo)
|
||||
self.assertEqual(ordered, None)
|
||||
|
||||
class ApplyTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.items = []
|
||||
|
|
|
|||
Loading…
Reference in a new issue