5
5
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
6
6
7
7
import os , sys
8
- from git .test .lib import ( TestBase ,
9
- patch ,
8
+ from git .test .lib import (
9
+ TestBase ,
10
+ patch ,
10
11
raises ,
11
12
assert_equal ,
12
13
assert_true ,
16
17
GitCommandError )
17
18
18
19
class TestGit (TestBase ):
19
-
20
+
20
21
@classmethod
21
22
def setUp (cls ):
22
23
super (TestGit , cls ).setUp ()
@@ -29,6 +30,14 @@ def test_call_process_calls_execute(self, git):
29
30
assert_true (git .called )
30
31
assert_equal (git .call_args , ((['git' , 'version' ],), {}))
31
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
+
32
41
@raises (GitCommandError )
33
42
def test_it_raises_errors (self ):
34
43
self .git .this_does_not_exist ()
@@ -58,7 +67,7 @@ def test_it_ignores_false_kwargs(self, git):
58
67
# this_should_not_be_ignored=False implies it *should* be ignored
59
68
output = self .git .version (pass_this_kwarg = False )
60
69
assert_true ("pass_this_kwarg" not in git .call_args [1 ])
61
-
70
+
62
71
def test_persistent_cat_file_command (self ):
63
72
# read header only
64
73
import subprocess as sp
@@ -67,37 +76,37 @@ def test_persistent_cat_file_command(self):
67
76
g .stdin .write ("b2339455342180c7cc1e9bba3e9f181f7baa5167\n " )
68
77
g .stdin .flush ()
69
78
obj_info = g .stdout .readline ()
70
-
79
+
71
80
# read header + data
72
81
g = self .git .cat_file (batch = True , istream = sp .PIPE ,as_process = True )
73
82
g .stdin .write ("b2339455342180c7cc1e9bba3e9f181f7baa5167\n " )
74
83
g .stdin .flush ()
75
84
obj_info_two = g .stdout .readline ()
76
85
assert obj_info == obj_info_two
77
-
86
+
78
87
# read data - have to read it in one large chunk
79
88
size = int (obj_info .split ()[2 ])
80
89
data = g .stdout .read (size )
81
90
terminating_newline = g .stdout .read (1 )
82
-
91
+
83
92
# now we should be able to read a new object
84
93
g .stdin .write ("b2339455342180c7cc1e9bba3e9f181f7baa5167\n " )
85
94
g .stdin .flush ()
86
95
assert g .stdout .readline () == obj_info
87
-
88
-
96
+
97
+
89
98
# same can be achived using the respective command functions
90
99
hexsha , typename , size = self .git .get_object_header (hexsha )
91
100
hexsha , typename_two , size_two , data = self .git .get_object_data (hexsha )
92
101
assert typename == typename_two and size == size_two
93
-
102
+
94
103
def test_version (self ):
95
104
v = self .git .version_info
96
105
assert isinstance (v , tuple )
97
106
for n in v :
98
107
assert isinstance (n , int )
99
108
#END verify number types
100
-
109
+
101
110
def test_cmd_override (self ):
102
111
prev_cmd = self .git .GIT_PYTHON_GIT_EXECUTABLE
103
112
try :
0 commit comments