Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf03e616

Browse files
craigezdbaxa
authored andcommitted
Basic test for __unpack_args to verify unicode handling works
(cherry picked from commit8fa25b1)Signed-off-by: David Black <dblack@atlassian.com>Conflicts:git/test/test_git.py
1 parent64a4730 commitf03e616

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
importos,sys
8-
fromgit.test.libimport (TestBase,
9-
patch,
8+
fromgit.test.libimport (
9+
TestBase,
10+
patch,
1011
raises,
1112
assert_equal,
1213
assert_true,
@@ -16,7 +17,7 @@
1617
GitCommandError )
1718

1819
classTestGit(TestBase):
19-
20+
2021
@classmethod
2122
defsetUp(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+
deftest_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+
deftest_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
deftest_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"notingit.call_args[1])
61-
70+
6271
deftest_persistent_cat_file_command(self):
6372
# read header only
6473
importsubprocessassp
@@ -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
assertobj_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
assertg.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
asserttypename==typename_twoandsize==size_two
93-
102+
94103
deftest_version(self):
95104
v=self.git.version_info
96105
assertisinstance(v,tuple)
97106
forninv:
98107
assertisinstance(n,int)
99108
#END verify number types
100-
109+
101110
deftest_cmd_override(self):
102111
prev_cmd=self.git.GIT_PYTHON_GIT_EXECUTABLE
103112
try:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp