Ensure that find_files only returns unicode
This commit is contained in:
parent
a078a7448e
commit
dd259d0797
@ -48,12 +48,14 @@ def split_path(path):
|
|||||||
def find_files(path):
|
def find_files(path):
|
||||||
path = os.path.expanduser(path)
|
path = os.path.expanduser(path)
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
yield os.path.abspath(path)
|
filename = os.path.abspath(path)
|
||||||
|
yield filename.decode('utf-8')
|
||||||
else:
|
else:
|
||||||
for dirpath, dirnames, filenames in os.walk(path):
|
for dirpath, dirnames, filenames in os.walk(path):
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
dirpath = os.path.abspath(dirpath)
|
dirpath = os.path.abspath(dirpath)
|
||||||
yield os.path.join(dirpath, filename)
|
filename = os.path.join(dirpath, filename)
|
||||||
|
yield filename.decode('utf-8')
|
||||||
|
|
||||||
class Mtime(object):
|
class Mtime(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@ -133,6 +133,12 @@ class FindFilesTest(unittest.TestCase):
|
|||||||
self.assertEqual(len(files), 1)
|
self.assertEqual(len(files), 1)
|
||||||
self.assert_(files[0], data_folder('blank.mp3'))
|
self.assert_(files[0], data_folder('blank.mp3'))
|
||||||
|
|
||||||
|
def test_names_are_unicode(self):
|
||||||
|
is_unicode = lambda f: isinstance(f, unicode)
|
||||||
|
for name in self.find(''):
|
||||||
|
self.assert_(is_unicode(name),
|
||||||
|
'%s is not unicode object' % repr(name))
|
||||||
|
|
||||||
def test_expanduser(self):
|
def test_expanduser(self):
|
||||||
raise SkipTest
|
raise SkipTest
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user