mirror of
https://github.com/beetbox/beets.git
synced 2025-12-16 05:34:47 +01:00
summarize_items(): sort format by decr. freq
Make the summary deterministic.
This commit is contained in:
parent
1e2d481ac0
commit
8e25a70e40
2 changed files with 7 additions and 3 deletions
|
|
@ -437,8 +437,9 @@ def summarize_items(items, singleton):
|
|||
# A single format.
|
||||
summary_parts.append(items[0].format)
|
||||
else:
|
||||
# Enumerate all the formats.
|
||||
for fmt, count in format_counts.iteritems():
|
||||
# Enumerate all the formats by decreasing frequencies:
|
||||
for fmt, count in sorted(format_counts.items(),
|
||||
key=lambda (f, c): (-c, f)):
|
||||
summary_parts.append('{0} {1}'.format(fmt, count))
|
||||
|
||||
if items:
|
||||
|
|
|
|||
|
|
@ -1005,7 +1005,10 @@ class SummarizeItemsTest(_common.TestCase):
|
|||
|
||||
i2.format = "G"
|
||||
summary = commands.summarize_items([self.item, i2], False)
|
||||
self.assertEqual(summary, "2 items, G 1, F 1, 4kbps, 21:48, 1.9 KB")
|
||||
self.assertEqual(summary, "2 items, F 1, G 1, 4kbps, 21:48, 1.9 KB")
|
||||
|
||||
summary = commands.summarize_items([self.item, i2, i2], False)
|
||||
self.assertEqual(summary, "3 items, G 2, F 1, 4kbps, 32:42, 2.9 KB")
|
||||
|
||||
|
||||
class PathFormatTest(_common.TestCase):
|
||||
|
|
|
|||
Loading…
Reference in a new issue