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