55# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66
77import os ,sys
8- from git .test .lib import (TestBase ,
9- patch ,
8+ from git .test .lib import (
9+ TestBase ,
10+ patch ,
1011raises ,
1112assert_equal ,
1213assert_true ,
1617GitCommandError )
1718
1819class TestGit (TestBase ):
19-
20+
2021@classmethod
2122def setUp (cls ):
2223super (TestGit ,cls ).setUp ()
@@ -29,6 +30,14 @@ def test_call_process_calls_execute(self, git):
2930assert_true (git .called )
3031assert_equal (git .call_args , ((['git' ,'version' ],), {}))
3132
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+
3241@raises (GitCommandError )
3342def test_it_raises_errors (self ):
3443self .git .this_does_not_exist ()
@@ -58,7 +67,7 @@ def test_it_ignores_false_kwargs(self, git):
5867# this_should_not_be_ignored=False implies it *should* be ignored
5968output = self .git .version (pass_this_kwarg = False )
6069assert_true ("pass_this_kwarg" not in git .call_args [1 ])
61-
70+
6271def test_persistent_cat_file_command (self ):
6372# read header only
6473import subprocess as sp
@@ -67,37 +76,37 @@ def test_persistent_cat_file_command(self):
6776g .stdin .write ("b2339455342180c7cc1e9bba3e9f181f7baa5167\n " )
6877g .stdin .flush ()
6978obj_info = g .stdout .readline ()
70-
79+
7180# read header + data
7281g = self .git .cat_file (batch = True ,istream = sp .PIPE ,as_process = True )
7382g .stdin .write ("b2339455342180c7cc1e9bba3e9f181f7baa5167\n " )
7483g .stdin .flush ()
7584obj_info_two = g .stdout .readline ()
7685assert obj_info == obj_info_two
77-
86+
7887# read data - have to read it in one large chunk
7988size = int (obj_info .split ()[2 ])
8089data = g .stdout .read (size )
8190terminating_newline = g .stdout .read (1 )
82-
91+
8392# now we should be able to read a new object
8493g .stdin .write ("b2339455342180c7cc1e9bba3e9f181f7baa5167\n " )
8594g .stdin .flush ()
8695assert g .stdout .readline ()== obj_info
87-
88-
96+
97+
8998# same can be achived using the respective command functions
9099hexsha ,typename ,size = self .git .get_object_header (hexsha )
91100hexsha ,typename_two ,size_two ,data = self .git .get_object_data (hexsha )
92101assert typename == typename_two and size == size_two
93-
102+
94103def test_version (self ):
95104v = self .git .version_info
96105assert isinstance (v ,tuple )
97106for n in v :
98107assert isinstance (n ,int )
99108#END verify number types
100-
109+
101110def test_cmd_override (self ):
102111prev_cmd = self .git .GIT_PYTHON_GIT_EXECUTABLE
103112try :