From 02d8e88ef157760bd25f17f6c790b4b3578054c0 Mon Sep 17 00:00:00 2001 From: Bruno Cauet Date: Tue, 20 Jan 2015 12:48:15 +0100 Subject: [PATCH] Replace all mentions of 'str' with 'bytes' --- beets/autotag/hooks.py | 4 ++-- beets/autotag/match.py | 4 ++-- beets/autotag/mb.py | 2 +- beets/dbcore/query.py | 6 +++--- beets/library.py | 6 +++--- beets/mediafile.py | 10 +++++----- beets/ui/__init__.py | 4 ++-- beets/util/__init__.py | 2 +- beets/util/artresizer.py | 2 +- beets/util/bluelet.py | 4 ++-- beets/util/confit.py | 2 +- beetsplug/bpd/gstplayer.py | 2 +- beetsplug/bucket.py | 4 ++-- beetsplug/chroma.py | 2 +- beetsplug/convert.py | 2 +- beetsplug/duplicates.py | 2 +- beetsplug/lastimport.py | 4 ++-- beetsplug/lyrics.py | 2 +- beetsplug/permissions.py | 2 +- beetsplug/replaygain.py | 2 +- extra/release.py | 2 +- test/_common.py | 2 +- test/helper.py | 6 +++--- test/test_autotag.py | 2 +- test/test_config_command.py | 2 +- test/test_library.py | 16 ++++++++-------- test/test_mb.py | 2 +- test/test_mediafile.py | 6 ++++-- test/test_mediafile_edge.py | 4 ++-- test/test_query.py | 6 +++--- test/test_spotify.py | 4 ++-- test/test_ui.py | 6 +++--- test/test_ui_importer.py | 2 +- 33 files changed, 65 insertions(+), 63 deletions(-) diff --git a/beets/autotag/hooks.py b/beets/autotag/hooks.py index 5d0d85b87..c8e068e62 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -112,7 +112,7 @@ class AlbumInfo(object): 'catalognum', 'script', 'language', 'country', 'albumstatus', 'albumdisambig', 'artist_credit', 'media']: value = getattr(self, fld) - if isinstance(value, str): + if isinstance(value, bytes): setattr(self, fld, value.decode(codec, 'ignore')) if self.tracks: @@ -171,7 +171,7 @@ class TrackInfo(object): for fld in ['title', 'artist', 'medium', 'artist_sort', 'disctitle', 'artist_credit', 'media']: value = getattr(self, fld) - if isinstance(value, str): + if isinstance(value, bytes): setattr(self, fld, value.decode(codec, 'ignore')) diff --git a/beets/autotag/match.py b/beets/autotag/match.py index 6d8a154fb..ed02cdf6b 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -407,7 +407,7 @@ def tag_album(items, search_artist=None, search_album=None, if id_info: _add_candidate(items, candidates, id_info) rec = _recommendation(candidates.values()) - log.debug(u'Album ID match recommendation is {0}', str(rec)) + log.debug(u'Album ID match recommendation is {0}', rec) if candidates and not config['import']['timid']: # If we have a very good MBID match, return immediately. # Otherwise, this match will compete against metadata-based @@ -426,7 +426,7 @@ def tag_album(items, search_artist=None, search_album=None, va_likely = ((not consensus['artist']) or (search_artist.lower() in VA_ARTISTS) or any(item.comp for item in items)) - log.debug(u'Album might be VA: {0}', str(va_likely)) + log.debug(u'Album might be VA: {0}', va_likely) # Get the results from the data sources. search_cands = hooks.album_candidates(items, search_artist, diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 010472616..1cf92ce5d 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -319,7 +319,7 @@ def match_album(artist, album, tracks=None): # Various Artists search. criteria['arid'] = VARIOUS_ARTISTS_ID if tracks is not None: - criteria['tracks'] = str(tracks) + criteria['tracks'] = bytes(tracks) # Abort if we have no search terms. if not any(criteria.itervalues()): diff --git a/beets/dbcore/query.py b/beets/dbcore/query.py index f615d645b..8379b725a 100644 --- a/beets/dbcore/query.py +++ b/beets/dbcore/query.py @@ -181,7 +181,7 @@ class BooleanQuery(MatchQuery): class BytesQuery(MatchQuery): """Match a raw bytes field (i.e., a path). This is a necessary hack - to work around the `sqlite3` module's desire to treat `str` and + to work around the `sqlite3` module's desire to treat `bytes` and `unicode` equivalently in Python 2. Always use this query instead of `MatchQuery` when matching on BLOB values. """ @@ -426,7 +426,7 @@ class Period(object): precision (a string, one of "year", "month", or "day"). """ if precision not in Period.precisions: - raise ValueError('Invalid precision ' + str(precision)) + raise ValueError('Invalid precision {0}'.format(precision)) self.date = date self.precision = precision @@ -466,7 +466,7 @@ class Period(object): elif 'day' == precision: return date + timedelta(days=1) else: - raise ValueError('unhandled precision ' + str(precision)) + raise ValueError('unhandled precision {0}'.format(precision)) class DateInterval(object): diff --git a/beets/library.py b/beets/library.py index 19706dd0d..488be5cfb 100644 --- a/beets/library.py +++ b/beets/library.py @@ -121,7 +121,7 @@ class PathType(types.Type): return self.normalize(sql_value) def to_sql(self, value): - if isinstance(value, str): + if isinstance(value, bytes): value = buffer(value) return value @@ -410,7 +410,7 @@ class Item(LibModel): if isinstance(value, unicode): value = bytestring_path(value) elif isinstance(value, buffer): - value = str(value) + value = bytes(value) if key in MediaFile.fields(): self.mtime = 0 # Reset mtime on dirty. @@ -513,7 +513,7 @@ class Item(LibModel): self.write(path) return True except FileOperationError as exc: - log.error(str(exc)) + log.error("{0}", exc) return False def try_sync(self, write=None): diff --git a/beets/mediafile.py b/beets/mediafile.py index e2ccb9267..26a630ce6 100644 --- a/beets/mediafile.py +++ b/beets/mediafile.py @@ -144,7 +144,7 @@ def _safe_cast(out_type, val): return False elif out_type == unicode: - if isinstance(val, str): + if isinstance(val, bytes): return val.decode('utf8', 'ignore') elif isinstance(val, unicode): return val @@ -450,7 +450,7 @@ class StorageStyle(object): if isinstance(value, bool): # Store bools as 1/0 instead of True/False. value = unicode(int(bool(value))) - elif isinstance(value, str): + elif isinstance(value, bytes): value = value.decode('utf8', 'ignore') else: value = unicode(value) @@ -738,7 +738,7 @@ class MP3DescStorageStyle(MP3StorageStyle): # need to make a new frame? if not found: frame = mutagen.id3.Frames[self.key]( - desc=str(self.description), + desc=bytes(self.description), text=value, encoding=3 ) @@ -811,7 +811,7 @@ class MP3ImageStorageStyle(ListStorageStyle, MP3StorageStyle): """ def __init__(self): super(MP3ImageStorageStyle, self).__init__(key='APIC') - self.as_type = str + self.as_type = bytes def deserialize(self, apic_frame): """Convert APIC frame into Image.""" @@ -880,7 +880,7 @@ class VorbisImageStorageStyle(ListStorageStyle): super(VorbisImageStorageStyle, self).__init__( key='metadata_block_picture' ) - self.as_type = str + self.as_type = bytes def fetch(self, mutagen_file): images = [] diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py index ee2537da1..eef331e62 100644 --- a/beets/ui/__init__.py +++ b/beets/ui/__init__.py @@ -219,11 +219,11 @@ def input_options(options, require=False, prompt=None, fallback_prompt=None, prompt_part_lengths = [] if numrange: if isinstance(default, int): - default_name = str(default) + default_name = unicode(default) default_name = colorize('turquoise', default_name) tmpl = '# selection (default %s)' prompt_parts.append(tmpl % default_name) - prompt_part_lengths.append(len(tmpl % str(default))) + prompt_part_lengths.append(len(tmpl % unicode(default))) else: prompt_parts.append('# selection') prompt_part_lengths.append(len(prompt_parts[-1])) diff --git a/beets/util/__init__.py b/beets/util/__init__.py index 0d5a70e72..6a3215606 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -312,7 +312,7 @@ def _fsencoding(): def bytestring_path(path): - """Given a path, which is either a str or a unicode, returns a str + """Given a path, which is either a bytes or a unicode, returns a str path (ensuring that we never deal with Unicode pathnames). """ # Pass through bytestrings. diff --git a/beets/util/artresizer.py b/beets/util/artresizer.py index d47a30a1c..b1920d8ac 100644 --- a/beets/util/artresizer.py +++ b/beets/util/artresizer.py @@ -43,7 +43,7 @@ def resize_url(url, maxwidth): """ return '{0}?{1}'.format(PROXY_URL, urllib.urlencode({ 'url': url.replace('http://', ''), - 'w': str(maxwidth), + 'w': bytes(maxwidth), })) diff --git a/beets/util/bluelet.py b/beets/util/bluelet.py index 6dcd92a1b..2fa10a57c 100644 --- a/beets/util/bluelet.py +++ b/beets/util/bluelet.py @@ -553,7 +553,7 @@ def spawn(coro): and child coroutines run concurrently. """ if not isinstance(coro, types.GeneratorType): - raise ValueError('%s is not a coroutine' % str(coro)) + raise ValueError('%s is not a coroutine' % coro) return SpawnEvent(coro) @@ -563,7 +563,7 @@ def call(coro): returns a value using end(), then this event returns that value. """ if not isinstance(coro, types.GeneratorType): - raise ValueError('%s is not a coroutine' % str(coro)) + raise ValueError('%s is not a coroutine' % coro) return DelegationEvent(coro) diff --git a/beets/util/confit.py b/beets/util/confit.py index 88aae3459..f86091fa2 100644 --- a/beets/util/confit.py +++ b/beets/util/confit.py @@ -247,7 +247,7 @@ class ConfigView(object): def __str__(self): """Gets the value for this view as a byte string.""" - return str(self.get()) + return bytes(self.get()) def __unicode__(self): """Gets the value for this view as a unicode string. (Python 2 diff --git a/beetsplug/bpd/gstplayer.py b/beetsplug/bpd/gstplayer.py index a06e1ce11..bb7e41960 100644 --- a/beetsplug/bpd/gstplayer.py +++ b/beetsplug/bpd/gstplayer.py @@ -89,7 +89,7 @@ class GstPlayer(object): # error self.player.set_state(gst.STATE_NULL) err, debug = message.parse_error() - print("Error: " + str(err)) + print("Error: {0}".format(err)) self.playing = False def _set_volume(self, volume): diff --git a/beetsplug/bucket.py b/beetsplug/bucket.py index 650852917..530808e41 100644 --- a/beetsplug/bucket.py +++ b/beetsplug/bucket.py @@ -133,9 +133,9 @@ def str2fmt(s): def format_span(fmt, yearfrom, yearto, fromnchars, tonchars): """Return a span string representation. """ - args = (str(yearfrom)[-fromnchars:]) + args = (bytes(yearfrom)[-fromnchars:]) if tonchars: - args = (str(yearfrom)[-fromnchars:], str(yearto)[-tonchars:]) + args = (bytes(yearfrom)[-fromnchars:], bytes(yearto)[-tonchars:]) return fmt % args diff --git a/beetsplug/chroma.py b/beetsplug/chroma.py index 78900134a..49157c413 100644 --- a/beetsplug/chroma.py +++ b/beetsplug/chroma.py @@ -64,7 +64,7 @@ def acoustid_match(log, path): duration, fp = acoustid.fingerprint_file(util.syspath(path)) except acoustid.FingerprintGenerationError as exc: log.error(u'fingerprinting of {0} failed: {1}', - util.displayable_path(repr(path)), str(exc)) + util.displayable_path(repr(path)), exc) return None _fingerprints[path] = fp try: diff --git a/beetsplug/convert.py b/beetsplug/convert.py index 7fef667a6..3470132b4 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -65,7 +65,7 @@ def get_format(format=None): .format(format) ) except ConfigTypeError: - command = config['convert']['formats'][format].get(str) + command = config['convert']['formats'][format].get(bytes) extension = format # Convenience and backwards-compatibility shortcuts. diff --git a/beetsplug/duplicates.py b/beetsplug/duplicates.py index aedbc677e..613eed466 100644 --- a/beetsplug/duplicates.py +++ b/beetsplug/duplicates.py @@ -87,7 +87,7 @@ def _group_by(objs, keys, log): counts[key].append(obj) else: log.debug(u'{0}: all keys {1} on item {2} are null: skipping', - PLUGIN, str(keys), displayable_path(obj.path)) + PLUGIN, keys, displayable_path(obj.path)) return counts diff --git a/beetsplug/lastimport.py b/beetsplug/lastimport.py index 53a971f40..b527c13ff 100644 --- a/beetsplug/lastimport.py +++ b/beetsplug/lastimport.py @@ -107,8 +107,8 @@ def fetch_tracks(user, page, limit): 'method': 'library.gettracks', 'user': user, 'api_key': plugins.LASTFM_KEY, - 'page': str(page), - 'limit': str(limit), + 'page': bytes(page), + 'limit': bytes(limit), 'format': 'json', }).json() diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 61baec019..f65fddd0b 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -56,7 +56,7 @@ URL_CHARACTERS = { def unescape(text): """Resolves &#xxx; HTML entities (and some others).""" - if isinstance(text, str): + if isinstance(text, bytes): text = text.decode('utf8', 'ignore') out = text.replace(u' ', u' ') diff --git a/beetsplug/permissions.py b/beetsplug/permissions.py index 625779847..a8aac3075 100644 --- a/beetsplug/permissions.py +++ b/beetsplug/permissions.py @@ -16,7 +16,7 @@ def convert_perm(perm): to an oct int. Else it just converts it to oct. """ if isinstance(perm, int): - return int(str(perm), 8) + return int(bytes(perm), 8) else: return int(perm, 8) diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py index b64afe54a..f42886632 100644 --- a/beetsplug/replaygain.py +++ b/beetsplug/replaygain.py @@ -179,7 +179,7 @@ class CommandBackend(Backend): # Disable clipping warning. cmd = cmd + ['-c'] cmd = cmd + ['-a' if is_album else '-r'] - cmd = cmd + ['-d', str(self.gain_offset)] + cmd = cmd + ['-d', bytes(self.gain_offset)] cmd = cmd + [syspath(i.path) for i in items] self._log.debug(u'analyzing {0} files', len(items)) diff --git a/extra/release.py b/extra/release.py index 0be3fabf4..f95ca3f0d 100755 --- a/extra/release.py +++ b/extra/release.py @@ -277,7 +277,7 @@ def prep(): # FIXME It should be possible to specify this as an argument. version_parts = [int(n) for n in cur_version.split('.')] version_parts[-1] += 1 - next_version = '.'.join(map(str, version_parts)) + next_version = u'.'.join(map(unicode, version_parts)) bump_version(next_version) diff --git a/test/_common.py b/test/_common.py index 076ab939b..6e6071534 100644 --- a/test/_common.py +++ b/test/_common.py @@ -75,7 +75,7 @@ def item(lib=None): comments=u'the comments', bpm=8, comp=True, - path='somepath' + str(_item_ident), + path='somepath{0}'.format(_item_ident), length=60.0, bitrate=128000, format='FLAC', diff --git a/test/helper.py b/test/helper.py index a9ec3efc7..05fb75bed 100644 --- a/test/helper.py +++ b/test/helper.py @@ -62,7 +62,7 @@ class LogCapture(logging.Handler): self.messages = [] def emit(self, record): - self.messages.append(str(record.msg)) + self.messages.append(unicode(record.msg)) @contextmanager @@ -326,7 +326,7 @@ class TestHelper(object): items = [] path = os.path.join(_common.RSRC, 'full.' + ext) for i in range(count): - item = Item.from_path(str(path)) + item = Item.from_path(bytes(path)) item.album = u'\u00e4lbum {0}'.format(i) # Check unicode paths item.title = u't\u00eftle {0}'.format(i) item.add(self.lib) @@ -341,7 +341,7 @@ class TestHelper(object): items = [] path = os.path.join(_common.RSRC, 'full.' + ext) for i in range(track_count): - item = Item.from_path(str(path)) + item = Item.from_path(bytes(path)) item.album = u'\u00e4lbum' # Check unicode paths item.title = u't\u00eftle {0}'.format(i) item.add(self.lib) diff --git a/test/test_autotag.py b/test/test_autotag.py index bc23b7342..7e018a4c1 100644 --- a/test/test_autotag.py +++ b/test/test_autotag.py @@ -572,7 +572,7 @@ class AssignmentTest(unittest.TestCase): return Item( artist=u'ben harper', album=u'burn to shine', - title=u'ben harper - Burn to Shine ' + str(i), + title=u'ben harper - Burn to Shine {0}'.format(i), track=i, length=length, mb_trackid='', mb_albumid='', mb_artistid='', diff --git a/test/test_config_command.py b/test/test_config_command.py index 3a9407d88..dcc09a554 100644 --- a/test/test_config_command.py +++ b/test/test_config_command.py @@ -106,7 +106,7 @@ class ConfigCommandTest(unittest.TestCase, TestHelper): execlp.side_effect = OSError() self.run_command('config', '-e') self.assertIn('Could not edit configuration', - str(user_error.exception.args[0])) + unicode(user_error.exception.args[0])) def test_edit_invalid_config_file(self): self.lib = Library(':memory:') diff --git a/test/test_library.py b/test/test_library.py index 961a156c9..335c8c095 100644 --- a/test/test_library.py +++ b/test/test_library.py @@ -924,22 +924,22 @@ class PathStringTest(_common.TestCase): self.i = item(self.lib) def test_item_path_is_bytestring(self): - self.assert_(isinstance(self.i.path, str)) + self.assert_(isinstance(self.i.path, bytes)) def test_fetched_item_path_is_bytestring(self): i = list(self.lib.items())[0] - self.assert_(isinstance(i.path, str)) + self.assert_(isinstance(i.path, bytes)) def test_unicode_path_becomes_bytestring(self): self.i.path = u'unicodepath' - self.assert_(isinstance(self.i.path, str)) + self.assert_(isinstance(self.i.path, bytes)) def test_unicode_in_database_becomes_bytestring(self): self.lib._connection().execute(""" update items set path=? where id=? """, (self.i.id, u'somepath')) i = list(self.lib.items())[0] - self.assert_(isinstance(i.path, str)) + self.assert_(isinstance(i.path, bytes)) def test_special_chars_preserved_in_database(self): path = 'b\xe1r'.encode('utf8') @@ -960,13 +960,13 @@ class PathStringTest(_common.TestCase): def test_destination_returns_bytestring(self): self.i.artist = u'b\xe1r' dest = self.i.destination() - self.assert_(isinstance(dest, str)) + self.assert_(isinstance(dest, bytes)) def test_art_destination_returns_bytestring(self): self.i.artist = u'b\xe1r' alb = self.lib.add_album([self.i]) dest = alb.art_destination(u'image.jpg') - self.assert_(isinstance(dest, str)) + self.assert_(isinstance(dest, bytes)) def test_artpath_stores_special_chars(self): path = b'b\xe1r' @@ -989,7 +989,7 @@ class PathStringTest(_common.TestCase): def test_unicode_artpath_becomes_bytestring(self): alb = self.lib.add_album([self.i]) alb.artpath = u'somep\xe1th' - self.assert_(isinstance(alb.artpath, str)) + self.assert_(isinstance(alb.artpath, bytes)) def test_unicode_artpath_in_database_decoded(self): alb = self.lib.add_album([self.i]) @@ -998,7 +998,7 @@ class PathStringTest(_common.TestCase): (u'somep\xe1th', alb.id) ) alb = self.lib.get_album(alb.id) - self.assert_(isinstance(alb.artpath, str)) + self.assert_(isinstance(alb.artpath, bytes)) class PathTruncationTest(_common.TestCase): diff --git a/test/test_mb.py b/test/test_mb.py index a38776811..837fd7860 100644 --- a/test/test_mb.py +++ b/test/test_mb.py @@ -65,7 +65,7 @@ class MBAlbumInfoTest(_common.TestCase): for i, recording in enumerate(tracks): track = { 'recording': recording, - 'position': str(i + 1), + 'position': bytes(i + 1), } if track_length: # Track lengths are distinct from recording lengths. diff --git a/test/test_mediafile.py b/test/test_mediafile.py index b86bc5e05..53cbef1c6 100644 --- a/test/test_mediafile.py +++ b/test/test_mediafile.py @@ -340,12 +340,14 @@ class ExtendedFieldTestMixin(object): def test_invalid_descriptor(self): with self.assertRaises(ValueError) as cm: MediaFile.add_field('somekey', True) - self.assertIn('must be an instance of MediaField', str(cm.exception)) + self.assertIn('must be an instance of MediaField', + unicode(cm.exception)) def test_overwrite_property(self): with self.assertRaises(ValueError) as cm: MediaFile.add_field('artist', MediaField()) - self.assertIn('property "artist" already exists', str(cm.exception)) + self.assertIn('property "artist" already exists', + unicode(cm.exception)) class ReadWriteTestBase(ArtTestMixin, GenreListTestMixin, diff --git a/test/test_mediafile_edge.py b/test/test_mediafile_edge.py index 55edf5ba5..3e828ac3e 100644 --- a/test/test_mediafile_edge.py +++ b/test/test_mediafile_edge.py @@ -292,7 +292,7 @@ class ID3v23Test(unittest.TestCase, TestHelper): mf.year = 2013 mf.save() frame = mf.mgfile['TDRC'] - self.assertTrue('2013' in str(frame)) + self.assertTrue('2013' in unicode(frame)) self.assertTrue('TYER' not in mf.mgfile) finally: self._delete_test() @@ -303,7 +303,7 @@ class ID3v23Test(unittest.TestCase, TestHelper): mf.year = 2013 mf.save() frame = mf.mgfile['TYER'] - self.assertTrue('2013' in str(frame)) + self.assertTrue('2013' in unicode(frame)) self.assertTrue('TDRC' not in mf.mgfile) finally: self._delete_test() diff --git a/test/test_query.py b/test/test_query.py index 505f1fb6d..065b95623 100644 --- a/test/test_query.py +++ b/test/test_query.py @@ -281,12 +281,12 @@ class GetTest(DummyDataTestCase): def test_invalid_query(self): with self.assertRaises(InvalidQueryError) as raised: dbcore.query.NumericQuery('year', '199a') - self.assertIn('not an int', str(raised.exception)) + self.assertIn('not an int', unicode(raised.exception)) with self.assertRaises(InvalidQueryError) as raised: dbcore.query.RegexpQuery('year', '199(') - self.assertIn('not a regular expression', str(raised.exception)) - self.assertIn('unbalanced parenthesis', str(raised.exception)) + self.assertIn('not a regular expression', unicode(raised.exception)) + self.assertIn('unbalanced parenthesis', unicode(raised.exception)) class MatchTest(_common.TestCase): diff --git a/test/test_spotify.py b/test/test_spotify.py index efa2ce084..48b84ff72 100644 --- a/test/test_spotify.py +++ b/test/test_spotify.py @@ -47,7 +47,7 @@ class SpotifyPluginTest(_common.TestCase, TestHelper): @responses.activate def test_missing_request(self): - response_body = str( + response_body = bytes( '{' '"tracks" : {' '"href" : "https://api.spotify.com/v1/search?query=duifhjslkef' @@ -83,7 +83,7 @@ class SpotifyPluginTest(_common.TestCase, TestHelper): @responses.activate def test_track_request(self): - response_body = str( + response_body = bytes( '{' '"tracks" : {' '"href" : "https://api.spotify.com/v1/search?query=Happy+album%3A' diff --git a/test/test_ui.py b/test/test_ui.py index 2d4d85cdd..3b327b9aa 100644 --- a/test/test_ui.py +++ b/test/test_ui.py @@ -650,7 +650,7 @@ class ConfigTest(unittest.TestCase, TestHelper): ui._raw_main(['test']) replacements = self.test_cmd.lib.replacements - self.assertEqual(replacements, [(re.compile(ur'[xy]'), u'z')]) + self.assertEqual(replacements, [(re.compile(r'[xy]'), b'z')]) def test_multiple_replacements_parsed(self): with self.write_config_file() as config: @@ -659,8 +659,8 @@ class ConfigTest(unittest.TestCase, TestHelper): ui._raw_main(['test']) replacements = self.test_cmd.lib.replacements self.assertEqual(replacements, [ - (re.compile(ur'[xy]'), u'z'), - (re.compile(ur'foo'), u'bar'), + (re.compile(r'[xy]'), 'z'), + (re.compile(r'foo'), 'bar'), ]) def test_cli_config_option(self): diff --git a/test/test_ui_importer.py b/test/test_ui_importer.py index 30a83488b..f2d33dcaf 100644 --- a/test/test_ui_importer.py +++ b/test/test_ui_importer.py @@ -67,7 +67,7 @@ class TestTerminalImportSession(TerminalImportSession): self.io.addinput('S') elif isinstance(choice, int): self.io.addinput('M') - self.io.addinput(str(choice)) + self.io.addinput(unicode(choice)) self._add_choice_input() else: raise Exception('Unknown choice %s' % choice)