示例#1
0
 def test_get_formatted_datetime(self):
     with _common.platform_posix():
         self.i.added = 1368302461.210265
         val = self.i.formatted().get('added')
     self.assertTrue(val.startswith('2013'))
示例#2
0
 def test_get_formatted_does_not_replace_separators(self):
     with _common.platform_posix():
         name = os.path.join('a', 'b')
         self.i.title = name
         newname = self.i.formatted().get('title')
     self.assertEqual(name, newname)
示例#3
0
 def test_get_formatted_uses_kbps_bitrate(self):
     with _common.platform_posix():
         self.i.bitrate = 12345
         val = self.i.formatted().get('bitrate')
     self.assertEqual(val, u'12kbps')
示例#4
0
 def test_get_formatted_datetime(self):
     with _common.platform_posix():
         self.i.added = 1368302461.210265
         val = self.i.formatted().get('added')
     self.assertTrue(val.startswith('2013'))
示例#5
0
 def _assert_dest(self, dest, i=None):
     if i is None:
         i = self.i
     with _common.platform_posix():
         actual = i.destination()
     self.assertEqual(actual, dest)
示例#6
0
 def test_get_formatted_does_not_replace_separators(self):
     with _common.platform_posix():
         name = os.path.join('a', 'b')
         self.i.title = name
         newname = self.i.formatted().get('title')
     self.assertEqual(name, newname)
示例#7
0
 def test_get_formatted_uses_kbps_bitrate(self):
     with _common.platform_posix():
         self.i.bitrate = 12345
         val = self.i.formatted().get('bitrate')
     self.assertEqual(val, u'12kbps')
示例#8
0
文件: test_util.py 项目: JDLH/beets
 def test_sanitize_with_custom_replace_adds_replacements(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'foo/bar', [
             (re.compile(r'foo'), u'bar'),
         ])
     self.assertEqual(p, u'bar/bar')
示例#9
0
文件: test_util.py 项目: JDLH/beets
 def test_sanitize_empty_component(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'foo//bar', [
             (re.compile(r'^$'), u'_'),
         ])
     self.assertEqual(p, u'foo/_/bar')
示例#10
0
文件: test_util.py 项目: JDLH/beets
 def test_sanitize_path_works_on_empty_string(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'')
     self.assertEqual(p, u'')
示例#11
0
文件: test_util.py 项目: JDLH/beets
 def test_sanitize_with_custom_replace_overrides_built_in_sub(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'a/.?/b', [
             (re.compile(r'foo'), u'bar'),
         ])
     self.assertEqual(p, u'a/.?/b')
示例#12
0
文件: test_util.py 项目: JDLH/beets
 def test_sanitize_unix_replaces_leading_dot(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'one/.two/three')
     self.assertFalse(u'.' in p)
示例#13
0
文件: test_util.py 项目: JDLH/beets
 def test_truncate_preserves_extension(self):
     with _common.platform_posix():
         p = util.truncate_path(u'abcde/fgh.ext', 5)
     self.assertEqual(p, u'abcde/f.ext')
示例#14
0
文件: test_util.py 项目: JDLH/beets
 def test_truncate_unicode(self):
     with _common.platform_posix():
         p = util.truncate_path(u'abcde/fgh', 4)
     self.assertEqual(p, u'abcd/fgh')
示例#15
0
 def _assert_dest(self, dest, i=None):
     if i is None:
         i = self.i
     with _common.platform_posix():
         actual = i.destination()
     self.assertEqual(actual, dest)
示例#16
0
 def test_syspath_posix_unchanged(self):
     with _common.platform_posix():
         path = os.path.join(u'a', u'b', u'c')
         outpath = util.syspath(path)
     self.assertEqual(path, outpath)
示例#17
0
文件: test_util.py 项目: JDLH/beets
 def test_truncate_bytestring(self):
     with _common.platform_posix():
         p = util.truncate_path(b'abcde/fgh', 4)
     self.assertEqual(p, b'abcd/fgh')
示例#18
0
 def test_truncate_bytestring(self):
     with _common.platform_posix():
         p = util.truncate_path(b'abcde/fgh', 4)
     self.assertEqual(p, b'abcd/fgh')
示例#19
0
 def test_get_formatted_pads_with_zero(self):
     with _common.platform_posix():
         self.i.track = 1
         name = self.i.formatted().get('track')
     self.assertTrue(name.startswith('0'))
示例#20
0
 def test_truncate_unicode(self):
     with _common.platform_posix():
         p = util.truncate_path(u'abcde/fgh', 4)
     self.assertEqual(p, u'abcd/fgh')
示例#21
0
 def test_get_formatted_uses_khz_samplerate(self):
     with _common.platform_posix():
         self.i.samplerate = 12345
         val = self.i.formatted().get('samplerate')
     self.assertEqual(val, u'12kHz')
示例#22
0
 def test_truncate_preserves_extension(self):
     with _common.platform_posix():
         p = util.truncate_path(u'abcde/fgh.ext', 5)
     self.assertEqual(p, u'abcde/f.ext')
示例#23
0
 def test_get_formatted_none(self):
     with _common.platform_posix():
         self.i.some_other_field = None
         val = self.i.formatted().get('some_other_field')
     self.assertEqual(val, u'')
示例#24
0
 def test_sanitize_unix_replaces_leading_dot(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'one/.two/three')
     self.assertFalse(u'.' in p)
示例#25
0
 def _assert_dest(self, dest):
     with _common.platform_posix():
         the_dest = self.i.destination()
     self.assertEqual(the_dest, b'/base/' + dest)
示例#26
0
 def test_sanitize_path_works_on_empty_string(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'')
     self.assertEqual(p, u'')
示例#27
0
 def test_get_formatted_pads_with_zero(self):
     with _common.platform_posix():
         self.i.track = 1
         name = self.i.formatted().get('track')
     self.assertTrue(name.startswith('0'))
示例#28
0
 def test_sanitize_with_custom_replace_overrides_built_in_sub(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'a/.?/b', [
             (re.compile(r'foo'), u'bar'),
         ])
     self.assertEqual(p, u'a/.?/b')
示例#29
0
 def test_get_formatted_uses_khz_samplerate(self):
     with _common.platform_posix():
         self.i.samplerate = 12345
         val = self.i.formatted().get('samplerate')
     self.assertEqual(val, u'12kHz')
示例#30
0
 def test_sanitize_with_custom_replace_adds_replacements(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'foo/bar', [
             (re.compile(r'foo'), u'bar'),
         ])
     self.assertEqual(p, u'bar/bar')
示例#31
0
 def test_get_formatted_none(self):
     with _common.platform_posix():
         self.i.some_other_field = None
         val = self.i.formatted().get('some_other_field')
     self.assertEqual(val, u'')
示例#32
0
 def test_sanitize_empty_component(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'foo//bar', [
             (re.compile(r'^$'), u'_'),
         ])
     self.assertEqual(p, u'foo/_/bar')
示例#33
0
 def _assert_dest(self, dest):
     with _common.platform_posix():
         the_dest = self.i.destination()
     self.assertEqual(the_dest, '/base/' + dest)
示例#34
0
文件: test_util.py 项目: JDLH/beets
 def test_syspath_posix_unchanged(self):
     with _common.platform_posix():
         path = os.path.join(u'a', u'b', u'c')
         outpath = util.syspath(path)
     self.assertEqual(path, outpath)