66
77import os ,sys
88from git .test .lib import (
9- TestBase ,
10- patch ,
9+ TestBase ,
10+ patch ,
1111raises ,
1212assert_equal ,
1313assert_true ,
1717from git import Git ,GitCommandError
1818
1919class TestGit (TestBase ):
20-
20+
2121@classmethod
2222def setUp (cls ):
2323super (TestGit ,cls ).setUp ()
@@ -30,6 +30,14 @@ def test_call_process_calls_execute(self, git):
3030assert_true (git .called )
3131assert_equal (git .call_args , ((['git' ,'version' ],), {}))
3232
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+
3341@raises (GitCommandError )
3442def test_it_raises_errors (self ):
3543self .git .this_does_not_exist ()
@@ -59,7 +67,7 @@ def test_it_ignores_false_kwargs(self, git):
5967# this_should_not_be_ignored=False implies it *should* be ignored
6068output = self .git .version (pass_this_kwarg = False )
6169assert_true ("pass_this_kwarg" not in git .call_args [1 ])
62-
70+
6371def test_persistent_cat_file_command (self ):
6472# read header only
6573import subprocess as sp
@@ -68,37 +76,37 @@ def test_persistent_cat_file_command(self):
6876g .stdin .write ("b2339455342180c7cc1e9bba3e9f181f7baa5167\n " )
6977g .stdin .flush ()
7078obj_info = g .stdout .readline ()
71-
79+
7280# read header + data
7381g = self .git .cat_file (batch = True ,istream = sp .PIPE ,as_process = True )
7482g .stdin .write ("b2339455342180c7cc1e9bba3e9f181f7baa5167\n " )
7583g .stdin .flush ()
7684obj_info_two = g .stdout .readline ()
7785assert obj_info == obj_info_two
78-
86+
7987# read data - have to read it in one large chunk
8088size = int (obj_info .split ()[2 ])
8189data = g .stdout .read (size )
8290terminating_newline = g .stdout .read (1 )
83-
91+
8492# now we should be able to read a new object
8593g .stdin .write ("b2339455342180c7cc1e9bba3e9f181f7baa5167\n " )
8694g .stdin .flush ()
8795assert g .stdout .readline ()== obj_info
88-
89-
96+
97+
9098# same can be achived using the respective command functions
9199hexsha ,typename ,size = self .git .get_object_header (hexsha )
92100hexsha ,typename_two ,size_two ,data = self .git .get_object_data (hexsha )
93101assert typename == typename_two and size == size_two
94-
102+
95103def test_version (self ):
96104v = self .git .version_info
97105assert isinstance (v ,tuple )
98106for n in v :
99107assert isinstance (n ,int )
100108#END verify number types
101-
109+
102110def test_cmd_override (self ):
103111prev_cmd = self .git .GIT_PYTHON_GIT_EXECUTABLE
104112try :
@@ -108,7 +116,7 @@ def test_cmd_override(self):
108116finally :
109117 type(self .git ).GIT_PYTHON_GIT_EXECUTABLE = prev_cmd
110118#END undo adjustment
111-
119+
112120def test_output_strip (self ):
113121import subprocess as sp
114122hexsha = "b2339455342180c7cc1e9bba3e9f181f7baa5167"