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

Commit8fa25b1

Browse files
committed
Basic test for __unpack_args to verify unicode handling works
1 parentca2b901 commit8fa25b1

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

‎git/test/test_cmd.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
importos,sys
88
fromgit.test.libimport (
9-
TestBase,
10-
patch,
9+
TestBase,
10+
patch,
1111
raises,
1212
assert_equal,
1313
assert_true,
@@ -17,7 +17,7 @@
1717
fromgitimportGit,GitCommandError
1818

1919
classTestGit(TestBase):
20-
20+
2121
@classmethod
2222
defsetUp(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+
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+
3341
@raises(GitCommandError)
3442
deftest_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"notingit.call_args[1])
62-
70+
6371
deftest_persistent_cat_file_command(self):
6472
# read header only
6573
importsubprocessassp
@@ -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
assertobj_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
assertg.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
asserttypename==typename_twoandsize==size_two
94-
102+
95103
deftest_version(self):
96104
v=self.git.version_info
97105
assertisinstance(v,tuple)
98106
forninv:
99107
assertisinstance(n,int)
100108
#END verify number types
101-
109+
102110
deftest_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
deftest_output_strip(self):
113121
importsubprocessassp
114122
hexsha="b2339455342180c7cc1e9bba3e9f181f7baa5167"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp