mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
now tolerates space-separated release times
--HG-- extra : convert_revision : svn%3A41726ec3-264d-0410-9c23-a9f1637257cc/trunk%40221
This commit is contained in:
parent
debebc616c
commit
f6b53142a9
4 changed files with 25 additions and 11 deletions
|
|
@ -117,8 +117,8 @@ class Packed(object):
|
|||
items = self.items
|
||||
if self.packstyle == packing.DATE:
|
||||
# Remove time information from dates. Usually delimited by
|
||||
# a "T".
|
||||
items = re.sub(r'[Tt].*$', '', unicode(items))
|
||||
# a "T" or a space.
|
||||
items = re.sub(r'[Tt ].*$', '', unicode(items))
|
||||
|
||||
# transform from a string packing into a list we can index into
|
||||
if self.packstyle == packing.SLASHED:
|
||||
|
|
|
|||
BIN
test/rsrc/space_time.mp3
Executable file
BIN
test/rsrc/space_time.mp3
Executable file
Binary file not shown.
|
|
@ -223,17 +223,33 @@ def suite_for_file(path, correct_dict, writing=True):
|
|||
return s
|
||||
|
||||
class EdgeTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.emptylist = beets.mediafile.MediaFile(
|
||||
os.path.join('rsrc', 'emptylist.mp3'))
|
||||
|
||||
def test_emptylist(self):
|
||||
# Some files have an ID3 frame that has a list with no elements.
|
||||
# This is very hard to produce, so this is just the first 8192
|
||||
# bytes of a file found "in the wild".
|
||||
genre = self.emptylist.genre
|
||||
emptylist = beets.mediafile.MediaFile(
|
||||
os.path.join('rsrc', 'emptylist.mp3'))
|
||||
genre = emptylist.genre
|
||||
self.assertEqual(genre, '')
|
||||
|
||||
def test_release_time_with_space(self):
|
||||
# Ensures that release times delimited by spaces are ignored.
|
||||
# Amie Street produces such files.
|
||||
space_time = beets.mediafile.MediaFile(
|
||||
os.path.join('rsrc', 'space_time.mp3'))
|
||||
self.assertEqual(space_time.year, 2009)
|
||||
self.assertEqual(space_time.month, 9)
|
||||
self.assertEqual(space_time.day, 4)
|
||||
|
||||
def test_release_time_with_t(self):
|
||||
# Ensures that release times delimited by Ts are ignored.
|
||||
# The iTunes Store produces such files.
|
||||
t_time = beets.mediafile.MediaFile(
|
||||
os.path.join('rsrc', 't_time.m4a'))
|
||||
self.assertEqual(t_time.year, 1987)
|
||||
self.assertEqual(t_time.month, 3)
|
||||
self.assertEqual(t_time.day, 31)
|
||||
|
||||
|
||||
def suite():
|
||||
s = unittest.TestSuite()
|
||||
|
|
@ -254,10 +270,6 @@ def suite():
|
|||
s.addTest(suite_for_file(os.path.join('rsrc', 'date.mp3'),
|
||||
correct_dicts['date']))
|
||||
|
||||
# Test for dates that include times (like iTunes purchases).
|
||||
s.addTest(suite_for_file(os.path.join('rsrc', 'time.m4a'),
|
||||
correct_dicts['date']))
|
||||
|
||||
# Read-only attribute tests.
|
||||
for fname, correct_dict in read_only_correct_dicts.iteritems():
|
||||
path = os.path.join('rsrc', fname)
|
||||
|
|
@ -266,6 +278,8 @@ def suite():
|
|||
|
||||
# Edge cases.
|
||||
s.addTest(EdgeTest('test_emptylist'))
|
||||
s.addTest(EdgeTest('test_release_time_with_t'))
|
||||
s.addTest(EdgeTest('test_release_time_with_space'))
|
||||
|
||||
return s
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue