Skip to content

Commit f03e616

Browse files
craigezdbaxa
authored andcommitted
Basic test for __unpack_args to verify unicode handling works
(cherry picked from commit 8fa25b1) Signed-off-by: David Black <dblack@atlassian.com> Conflicts: git/test/test_git.py
1 parent 64a4730 commit f03e616

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

git/test/test_git.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

77
import os, sys
8-
from git.test.lib import ( TestBase,
9-
patch,
8+
from git.test.lib import (
9+
TestBase,
10+
patch,
1011
raises,
1112
assert_equal,
1213
assert_true,
@@ -16,7 +17,7 @@
1617
GitCommandError )
1718

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy