add missing displayable_paths to satisify python -bb

This commit is contained in:
Johnny Robeson 2016-07-03 23:47:34 -04:00
parent 35d0e81949
commit 8c1e9e0dd4
3 changed files with 25 additions and 11 deletions

View file

@ -44,26 +44,35 @@ class TestHelper(helper.TestHelper):
def assertFileTag(self, path, tag): # noqa
"""Assert that the path is a file and the files content ends with `tag`.
"""
display_tag = tag
tag = tag.encode('utf-8')
self.assertTrue(os.path.isfile(path),
u'{0} is not a file'.format(path))
u'{0} is not a file'.format(
util.displayable_path(path)))
with open(path, 'rb') as f:
f.seek(-len(tag), os.SEEK_END)
f.seek(-len(display_tag), os.SEEK_END)
self.assertEqual(f.read(), tag,
u'{0} is not tagged with {1}'.format(path, tag))
u'{0} is not tagged with {1}'
.format(
util.displayable_path(path),
display_tag))
def assertNoFileTag(self, path, tag): # noqa
"""Assert that the path is a file and the files content does not
end with `tag`.
"""
display_tag = tag
tag = tag.encode('utf-8')
self.assertTrue(os.path.isfile(path),
u'{0} is not a file'.format(path))
u'{0} is not a file'.format(
util.displayable_path(path)))
with open(path, 'rb') as f:
f.seek(-len(tag), os.SEEK_END)
self.assertNotEqual(f.read(), tag,
u'{0} is unexpectedly tagged with {1}'
.format(path, tag))
.format(
util.displayable_path(path),
display_tag))
@_common.slow_test()

View file

@ -26,7 +26,7 @@ from test.helper import TestHelper
from beets.mediafile import MediaFile
from beets import config, logging, ui
from beets.util import syspath
from beets.util import syspath, displayable_path
from beets.util.artresizer import ArtResizer
from beets import art
@ -136,7 +136,7 @@ class EmbedartCliTest(_common.TestCase, TestHelper):
self.assertEqual(mediafile.images[0].data, self.image_data,
u'Image written is not {0}'.format(
self.abbey_artpath))
displayable_path(self.abbey_artpath)))
@require_artresizer_compare
def test_accept_similar_art(self):
@ -150,7 +150,7 @@ class EmbedartCliTest(_common.TestCase, TestHelper):
self.assertEqual(mediafile.images[0].data, self.image_data,
u'Image written is not {0}'.format(
self.abbey_similarpath))
displayable_path(self.abbey_similarpath)))
def test_non_ascii_album_path(self):
resource_path = os.path.join(_common.RSRC, b'image.mp3')

View file

@ -10,6 +10,7 @@ from mock import patch, Mock
from test._common import unittest
from test.helper import TestHelper
from beets.util import displayable_path
from beetsplug.permissions import (check_permissions,
convert_perm,
dirs_in_library)
@ -67,9 +68,13 @@ class PermissionsPluginTest(unittest.TestCase, TestHelper):
def assertPerms(self, path, typ, expect_success): # noqa
for x in [(True, self.exp_perms[expect_success][typ], '!='),
(False, self.exp_perms[not expect_success][typ], '==')]:
self.assertEqual(x[0], check_permissions(path, x[1]),
msg=u'{} : {} {} {}'.format(
path, oct(os.stat(path).st_mode), x[2], oct(x[1])))
msg = u'{} : {} {} {}'.format(
displayable_path(path),
oct(os.stat(path).st_mode),
x[2],
oct(x[1])
)
self.assertEqual(x[0], check_permissions(path, x[1]), msg=msg)
def test_convert_perm_from_string(self):
self.assertEqual(convert_perm('10'), 8)