Show More
@@ -1,47 +1,47 b'' | |||||
1 | from __future__ import absolute_import, print_function |
|
1 | from __future__ import absolute_import, print_function | |
2 |
|
2 | |||
3 | import io |
|
3 | import io | |
4 | import unittest |
|
4 | import unittest | |
5 |
|
5 | |||
6 | import silenttestrunner |
|
6 | import silenttestrunner | |
7 |
|
7 | |||
8 | from mercurial import ( |
|
8 | from mercurial import ( | |
9 | util, |
|
9 | util, | |
10 | wireproto, |
|
10 | wireproto, | |
11 | wireprotoserver, |
|
11 | wireprotoserver, | |
12 | ) |
|
12 | ) | |
13 |
|
13 | |||
14 | class SSHServerGetArgsTests(unittest.TestCase): |
|
14 | class SSHServerGetArgsTests(unittest.TestCase): | |
15 | def testparseknown(self): |
|
15 | def testparseknown(self): | |
16 | tests = [ |
|
16 | tests = [ | |
17 | ('* 0\nnodes 0\n', ['', {}]), |
|
17 | (b'* 0\nnodes 0\n', [b'', {}]), | |
18 | ('* 0\nnodes 40\n1111111111111111111111111111111111111111\n', |
|
18 | (b'* 0\nnodes 40\n1111111111111111111111111111111111111111\n', | |
19 | ['1111111111111111111111111111111111111111', {}]), |
|
19 | [b'1111111111111111111111111111111111111111', {}]), | |
20 | ] |
|
20 | ] | |
21 | for input, expected in tests: |
|
21 | for input, expected in tests: | |
22 | self.assertparse('known', input, expected) |
|
22 | self.assertparse(b'known', input, expected) | |
23 |
|
23 | |||
24 | def assertparse(self, cmd, input, expected): |
|
24 | def assertparse(self, cmd, input, expected): | |
25 | server = mockserver(input) |
|
25 | server = mockserver(input) | |
26 | _func, spec = wireproto.commands[cmd] |
|
26 | _func, spec = wireproto.commands[cmd] | |
27 | self.assertEqual(server._proto.getargs(spec), expected) |
|
27 | self.assertEqual(server._proto.getargs(spec), expected) | |
28 |
|
28 | |||
29 | def mockserver(inbytes): |
|
29 | def mockserver(inbytes): | |
30 | ui = mockui(inbytes) |
|
30 | ui = mockui(inbytes) | |
31 | repo = mockrepo(ui) |
|
31 | repo = mockrepo(ui) | |
32 | return wireprotoserver.sshserver(ui, repo) |
|
32 | return wireprotoserver.sshserver(ui, repo) | |
33 |
|
33 | |||
34 | class mockrepo(object): |
|
34 | class mockrepo(object): | |
35 | def __init__(self, ui): |
|
35 | def __init__(self, ui): | |
36 | self.ui = ui |
|
36 | self.ui = ui | |
37 |
|
37 | |||
38 | class mockui(object): |
|
38 | class mockui(object): | |
39 | def __init__(self, inbytes): |
|
39 | def __init__(self, inbytes): | |
40 | self.fin = io.BytesIO(inbytes) |
|
40 | self.fin = io.BytesIO(inbytes) | |
41 | self.fout = io.BytesIO() |
|
41 | self.fout = io.BytesIO() | |
42 | self.ferr = io.BytesIO() |
|
42 | self.ferr = io.BytesIO() | |
43 |
|
43 | |||
44 | if __name__ == '__main__': |
|
44 | if __name__ == '__main__': | |
45 | # Don't call into msvcrt to set BytesIO to binary mode |
|
45 | # Don't call into msvcrt to set BytesIO to binary mode | |
46 | util.setbinary = lambda fp: True |
|
46 | util.setbinary = lambda fp: True | |
47 | silenttestrunner.main(__name__) |
|
47 | silenttestrunner.main(__name__) |
General Comments 0
You need to be logged in to leave comments.
Login now