diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 6bd015576..359549227 100755 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -68,6 +68,8 @@ def _do_query(lib, query, album, also_items=True): def _showdiff(field, oldval, newval, color): """Prints out a human-readable field difference line.""" if newval != oldval: + oldval = unicode(newval) + newval = unicode(newval) if color: oldval, newval = ui.colordiff(oldval, newval) print_(u' %s: %s -> %s' % (field, oldval, newval)) diff --git a/test/test_ui.py b/test/test_ui.py index 6b56046bd..1bf6c5049 100644 --- a/test/test_ui.py +++ b/test/test_ui.py @@ -502,6 +502,28 @@ class ConfigTest(unittest.TestCase): library: /xxx/yyy/not/a/real/path """), func) +class UtilTest(unittest.TestCase): + def setUp(self): + self.io = _common.DummyIO() + self.io.install() + def tearDown(self): + self.io.restore() + + def test_showdiff_strings(self): + commands._showdiff('field', 'old', 'new', True) + out = self.io.getoutput() + self.assertTrue('field' in out) + + def test_showdiff_identical(self): + commands._showdiff('field', 'old', 'old', True) + out = self.io.getoutput() + self.assertFalse('field' in out) + + def test_showdiff_ints(self): + commands._showdiff('field', 2, 3, True) + out = self.io.getoutput() + self.assertTrue('field' in out) + def suite(): return unittest.TestLoader().loadTestsFromName(__name__)