mirror of
https://github.com/beetbox/beets.git
synced 2026-01-03 14:32:55 +01:00
fix unicode issue with manual search prompt (#113)
This commit is contained in:
parent
0f79c0f49e
commit
ca0d1bc7aa
4 changed files with 19 additions and 4 deletions
2
NEWS
2
NEWS
|
|
@ -29,6 +29,8 @@
|
|||
* When copying read-only files, the importer now tries to make the copy
|
||||
writable. (Previously, this would just crash the import.)
|
||||
* Fixed an UnboundLocalError when no matches are found during autotag.
|
||||
* Fixed a Unicode encoding error when entering special characters into
|
||||
the "manual search" prompt.
|
||||
|
||||
1.0b5
|
||||
-----
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ from __future__ import with_statement # Python 2.5
|
|||
import os
|
||||
import logging
|
||||
import pickle
|
||||
import sys
|
||||
|
||||
from beets import ui
|
||||
from beets.ui import print_
|
||||
|
|
@ -186,8 +187,8 @@ def choose_candidate(cur_artist, cur_album, candidates, rec, color=True):
|
|||
|
||||
def manual_search():
|
||||
"""Input an artist and album for manual search."""
|
||||
artist = raw_input('Artist: ')
|
||||
album = raw_input('Album: ')
|
||||
artist = raw_input('Artist: ').decode(sys.stdin.encoding)
|
||||
album = raw_input('Album: ').decode(sys.stdin.encoding)
|
||||
return artist.strip(), album.strip()
|
||||
|
||||
def tag_log(logfile, status, path):
|
||||
|
|
|
|||
|
|
@ -102,6 +102,19 @@ class PrintTest(unittest.TestCase):
|
|||
else:
|
||||
del os.environ['LC_CTYPE']
|
||||
|
||||
class InputTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
def my_input(prompt=None):
|
||||
return '\xc3\x82me'
|
||||
commands.raw_input = my_input
|
||||
def tearDown(self):
|
||||
commands.raw_input = raw_input
|
||||
|
||||
def test_manual_search_gets_unicode(self):
|
||||
artist, album = commands.manual_search()
|
||||
self.assertEqual(artist, u'\xc2me')
|
||||
self.assertEqual(album, u'\xc2me')
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import os
|
|||
import re
|
||||
import sys
|
||||
|
||||
pkgpath = os.path.dirname(__file__)
|
||||
pkgpath = os.path.dirname(__file__) or '.'
|
||||
sys.path.append(pkgpath)
|
||||
os.chdir(pkgpath)
|
||||
|
||||
|
|
@ -35,4 +35,3 @@ def suite():
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(defaultTest='suite')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue