mirror of
https://github.com/beetbox/beets.git
synced 2025-12-09 10:05:35 +01:00
Don't crash if non-canonical genre and prefer_specific: yes.
Also, add a test for this.
This commit is contained in:
parent
0148070445
commit
ee46a5150f
2 changed files with 12 additions and 0 deletions
|
|
@ -174,6 +174,7 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
genre tree.
|
||||
"""
|
||||
depth_tag_pairs = [(self._get_depth(t), t) for t in tags]
|
||||
depth_tag_pairs = [e for e in depth_tag_pairs if e[0] is not None]
|
||||
depth_tag_pairs.sort(reverse=True)
|
||||
return [p[1] for p in depth_tag_pairs]
|
||||
|
||||
|
|
|
|||
|
|
@ -213,6 +213,17 @@ class LastGenrePluginTest(unittest.TestCase, TestHelper):
|
|||
self.assertEqual(res, (config['lastgenre']['fallback'].get(),
|
||||
u'fallback'))
|
||||
|
||||
def test_sort_by_depth(self):
|
||||
self._setup_config(canonical=True,count=99)
|
||||
# Normal case.
|
||||
tags = ('electronic', 'ambient', 'post-rock', 'downtempo')
|
||||
res = self.plugin._sort_by_depth(tags)
|
||||
self.assertEqual(res, ['post-rock', 'downtempo', 'ambient', 'electronic'])
|
||||
# Non-canonical tag ('chillout') present.
|
||||
tags = ('electronic', 'ambient', 'chillout')
|
||||
res = self.plugin._sort_by_depth(tags)
|
||||
self.assertEqual(res, ['ambient', 'electronic'])
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
|
|
|||
Loading…
Reference in a new issue