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