summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Northway <craig.northway@gmail.com>2014-07-25 11:53:57 +1000
committerCraig Northway <craig.northway@gmail.com>2014-07-25 11:53:57 +1000
commit8fa25b1cd5a82679c7b12d546b96c30cafed0559 (patch)
tree392678f5257986dc6da20735675e28ba2b94f7ea
parentca2b901e7229fc5c793762fd4e4c1c38c5a78e80 (diff)
downloadgitpython-8fa25b1cd5a82679c7b12d546b96c30cafed0559.tar.gz
Basic test for __unpack_args to verify unicode handling works
-rw-r--r--git/test/test_cmd.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/git/test/test_cmd.py b/git/test/test_cmd.py
index 985cdad2..5f59c200 100644
--- a/git/test/test_cmd.py
+++ b/git/test/test_cmd.py
@@ -6,8 +6,8 @@
import os, sys
from git.test.lib import (
- TestBase,
- patch,
+ TestBase,
+ patch,
raises,
assert_equal,
assert_true,
@@ -17,7 +17,7 @@ from git.test.lib import (
from git import Git, GitCommandError
class TestGit(TestBase):
-
+
@classmethod
def setUp(cls):
super(TestGit, cls).setUp()
@@ -30,6 +30,14 @@ class TestGit(TestBase):
assert_true(git.called)
assert_equal(git.call_args, ((['git', 'version'],), {}))
+ def test_call_unpack_args_unicode(self):
+ args = Git._Git__unpack_args(u'Unicode' + unichr(40960))
+ assert_equal(args, ['Unicode\xea\x80\x80'])
+
+ def test_call_unpack_args(self):
+ args = Git._Git__unpack_args(['git', 'log', '--', u'Unicode' + unichr(40960)])
+ assert_equal(args, ['git', 'log', '--', 'Unicode\xea\x80\x80'])
+
@raises(GitCommandError)
def test_it_raises_errors(self):
self.git.this_does_not_exist()
@@ -59,7 +67,7 @@ class TestGit(TestBase):
# this_should_not_be_ignored=False implies it *should* be ignored
output = self.git.version(pass_this_kwarg=False)
assert_true("pass_this_kwarg" not in git.call_args[1])
-
+
def test_persistent_cat_file_command(self):
# read header only
import subprocess as sp
@@ -68,37 +76,37 @@ class TestGit(TestBase):
g.stdin.write("b2339455342180c7cc1e9bba3e9f181f7baa5167\n")
g.stdin.flush()
obj_info = g.stdout.readline()
-
+
# read header + data
g = self.git.cat_file(batch=True, istream=sp.PIPE,as_process=True)
g.stdin.write("b2339455342180c7cc1e9bba3e9f181f7baa5167\n")
g.stdin.flush()
obj_info_two = g.stdout.readline()
assert obj_info == obj_info_two
-
+
# read data - have to read it in one large chunk
size = int(obj_info.split()[2])
data = g.stdout.read(size)
terminating_newline = g.stdout.read(1)
-
+
# now we should be able to read a new object
g.stdin.write("b2339455342180c7cc1e9bba3e9f181f7baa5167\n")
g.stdin.flush()
assert g.stdout.readline() == obj_info
-
-
+
+
# same can be achived using the respective command functions
hexsha, typename, size = self.git.get_object_header(hexsha)
hexsha, typename_two, size_two, data = self.git.get_object_data(hexsha)
assert typename == typename_two and size == size_two
-
+
def test_version(self):
v = self.git.version_info
assert isinstance(v, tuple)
for n in v:
assert isinstance(n, int)
#END verify number types
-
+
def test_cmd_override(self):
prev_cmd = self.git.GIT_PYTHON_GIT_EXECUTABLE
try:
@@ -108,7 +116,7 @@ class TestGit(TestBase):
finally:
type(self.git).GIT_PYTHON_GIT_EXECUTABLE = prev_cmd
#END undo adjustment
-
+
def test_output_strip(self):
import subprocess as sp
hexsha = "b2339455342180c7cc1e9bba3e9f181f7baa5167"