mirror of
https://github.com/beetbox/beets.git
synced 2026-02-22 23:33:50 +01:00
Fix exception construction in util.command_output()
`cmd` being a byte string array, it should be joined by b" " and not u" ".
This commit is contained in:
parent
2f7128f1d7
commit
02855a44bd
2 changed files with 16 additions and 2 deletions
|
|
@ -664,7 +664,7 @@ def command_output(cmd, shell=False):
|
|||
if proc.returncode:
|
||||
raise subprocess.CalledProcessError(
|
||||
returncode=proc.returncode,
|
||||
cmd=' '.join(cmd),
|
||||
cmd=b' '.join(cmd),
|
||||
)
|
||||
return stdout
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,9 @@ from __future__ import (division, absolute_import, print_function,
|
|||
import sys
|
||||
import re
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from mock import patch
|
||||
from mock import patch, Mock
|
||||
|
||||
from test._common import unittest
|
||||
from test import _common
|
||||
|
|
@ -102,6 +103,19 @@ class UtilTest(unittest.TestCase):
|
|||
])
|
||||
self.assertEqual(p, u'foo/_/bar')
|
||||
|
||||
@patch('beets.util.subprocess.Popen')
|
||||
def test_command_output(self, mock_popen):
|
||||
def popen_fail(*args, **kwargs):
|
||||
m = Mock(returncode=1)
|
||||
m.communicate.return_value = None, None
|
||||
return m
|
||||
|
||||
mock_popen.side_effect = popen_fail
|
||||
with self.assertRaises(subprocess.CalledProcessError) as exc_context:
|
||||
util.command_output([b"taga", b"\xc3\xa9"])
|
||||
self.assertEquals(exc_context.exception.returncode, 1)
|
||||
self.assertEquals(exc_context.exception.cmd, b"taga \xc3\xa9")
|
||||
|
||||
|
||||
class PathConversionTest(_common.TestCase):
|
||||
def test_syspath_windows_format(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue