6
6
7
7
import os , sys
8
8
from git .test .lib import (
9
- TestBase ,
10
- patch ,
9
+ TestBase ,
10
+ patch ,
11
11
raises ,
12
12
assert_equal ,
13
13
assert_true ,
17
17
from git import Git , GitCommandError
18
18
19
19
class TestGit (TestBase ):
20
-
20
+
21
21
@classmethod
22
22
def setUp (cls ):
23
23
super (TestGit , cls ).setUp ()
@@ -30,6 +30,14 @@ def test_call_process_calls_execute(self, git):
30
30
assert_true (git .called )
31
31
assert_equal (git .call_args , ((['git' , 'version' ],), {}))
32
32
33
+ def test_call_unpack_args_unicode (self ):
34
+ args = Git ._Git__unpack_args (u'Unicode' + unichr (40960 ))
35
+ assert_equal (args , ['Unicode\xea \x80 \x80 ' ])
36
+
37
+ def test_call_unpack_args (self ):
38
+ args = Git ._Git__unpack_args (['git' , 'log' , '--' , u'Unicode' + unichr (40960 )])
39
+ assert_equal (args , ['git' , 'log' , '--' , 'Unicode\xea \x80 \x80 ' ])
40
+
33
41
@raises (GitCommandError )
34
42
def test_it_raises_errors (self ):
35
43
self .git .this_does_not_exist ()
@@ -59,7 +67,7 @@ def test_it_ignores_false_kwargs(self, git):
59
67
# this_should_not_be_ignored=False implies it *should* be ignored
60
68
output = self .git .version (pass_this_kwarg = False )
61
69
assert_true ("pass_this_kwarg" not in git .call_args [1 ])
62
-
70
+
63
71
def test_persistent_cat_file_command (self ):
64
72
# read header only
65
73
import subprocess as sp
@@ -68,37 +76,37 @@ def test_persistent_cat_file_command(self):
68
76
g .stdin .write ("b2339455342180c7cc1e9bba3e9f181f7baa5167\n " )
69
77
g .stdin .flush ()
70
78
obj_info = g .stdout .readline ()
71
-
79
+
72
80
# read header + data
73
81
g = self .git .cat_file (batch = True , istream = sp .PIPE ,as_process = True )
74
82
g .stdin .write ("b2339455342180c7cc1e9bba3e9f181f7baa5167\n " )
75
83
g .stdin .flush ()
76
84
obj_info_two = g .stdout .readline ()
77
85
assert obj_info == obj_info_two
78
-
86
+
79
87
# read data - have to read it in one large chunk
80
88
size = int (obj_info .split ()[2 ])
81
89
data = g .stdout .read (size )
82
90
terminating_newline = g .stdout .read (1 )
83
-
91
+
84
92
# now we should be able to read a new object
85
93
g .stdin .write ("b2339455342180c7cc1e9bba3e9f181f7baa5167\n " )
86
94
g .stdin .flush ()
87
95
assert g .stdout .readline () == obj_info
88
-
89
-
96
+
97
+
90
98
# same can be achived using the respective command functions
91
99
hexsha , typename , size = self .git .get_object_header (hexsha )
92
100
hexsha , typename_two , size_two , data = self .git .get_object_data (hexsha )
93
101
assert typename == typename_two and size == size_two
94
-
102
+
95
103
def test_version (self ):
96
104
v = self .git .version_info
97
105
assert isinstance (v , tuple )
98
106
for n in v :
99
107
assert isinstance (n , int )
100
108
#END verify number types
101
-
109
+
102
110
def test_cmd_override (self ):
103
111
prev_cmd = self .git .GIT_PYTHON_GIT_EXECUTABLE
104
112
try :
@@ -108,7 +116,7 @@ def test_cmd_override(self):
108
116
finally :
109
117
type(self .git ).GIT_PYTHON_GIT_EXECUTABLE = prev_cmd
110
118
#END undo adjustment
111
-
119
+
112
120
def test_output_strip (self ):
113
121
import subprocess as sp
114
122
hexsha = "b2339455342180c7cc1e9bba3e9f181f7baa5167"
0 commit comments