File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ def __getattribute__(self, name):
30
30
value = utils .git_config ('pw.{}' .format (name ))
31
31
if value :
32
32
LOG .debug ("Retrieved '{}' setting from git-config" .format (name ))
33
- value = value .decode ('utf-8' )
34
33
35
34
setattr (self , name , value )
36
35
Original file line number Diff line number Diff line change 7
7
import subprocess
8
8
import sys
9
9
10
+ if sys .version_info < (3 , 0 ):
11
+ _text = unicode # noqa
12
+ else :
13
+ _text = str # noqa
14
+
10
15
11
16
def trim (string , length = 70 ): # type: (str, int) -> str
12
17
"""Trim a string to the given length."""
@@ -22,9 +27,9 @@ def git_config(value):
22
27
try :
23
28
output = subprocess .check_output (['git' , 'config' , value ])
24
29
except subprocess .CalledProcessError :
25
- output = ''
30
+ output = b ''
26
31
27
- return output .strip ()
32
+ return output .decode ( 'utf-8' ). strip ()
28
33
29
34
30
35
def git_am (mbox , args ):
Original file line number Diff line number Diff line change 8
8
from git_pw import utils
9
9
10
10
11
- @mock .patch .object (utils .subprocess , 'check_output' , return_value = ' bar ' )
11
+ @mock .patch .object (utils .subprocess , 'check_output' , return_value = b ' bar ' )
12
12
def test_git_config (mock_subprocess ):
13
13
value = utils .git_config ('foo' )
14
14
15
15
assert value == 'bar'
16
16
mock_subprocess .assert_called_once_with (['git' , 'config' , 'foo' ])
17
17
18
18
19
+ @mock .patch .object (utils .subprocess , 'check_output' ,
20
+ return_value = b'\xf0 \x9f \xa4 \xb7 ' )
21
+ def test_git_config_unicode (mock_subprocess ):
22
+ value = utils .git_config ('foo' )
23
+
24
+ assert value == u'\U0001f937 '
25
+ mock_subprocess .assert_called_once_with (['git' , 'config' , 'foo' ])
26
+
27
+
19
28
@mock .patch .object (utils .subprocess , 'check_output' ,
20
29
side_effect = subprocess .CalledProcessError (1 , 'xyz' , '123' ))
21
30
def test_git_config_error (mock_subprocess ):
You can’t perform that action at this time.
0 commit comments