##// END OF EJS Templates
test-sshserver: stabilize for Windows
Matt Harbison -
r35790:7764ff13 default
parent child Browse files
Show More
@@ -1,44 +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 sshserver,
10 util,
10 11 wireproto,
11 12 )
12 13
13 14 class SSHServerGetArgsTests(unittest.TestCase):
14 15 def testparseknown(self):
15 16 tests = [
16 17 ('* 0\nnodes 0\n', ['', {}]),
17 18 ('* 0\nnodes 40\n1111111111111111111111111111111111111111\n',
18 19 ['1111111111111111111111111111111111111111', {}]),
19 20 ]
20 21 for input, expected in tests:
21 22 self.assertparse('known', input, expected)
22 23
23 24 def assertparse(self, cmd, input, expected):
24 25 server = mockserver(input)
25 26 _func, spec = wireproto.commands[cmd]
26 27 self.assertEqual(server.getargs(spec), expected)
27 28
28 29 def mockserver(inbytes):
29 30 ui = mockui(inbytes)
30 31 repo = mockrepo(ui)
31 32 return sshserver.sshserver(ui, repo)
32 33
33 34 class mockrepo(object):
34 35 def __init__(self, ui):
35 36 self.ui = ui
36 37
37 38 class mockui(object):
38 39 def __init__(self, inbytes):
39 40 self.fin = io.BytesIO(inbytes)
40 41 self.fout = io.BytesIO()
41 42 self.ferr = io.BytesIO()
42 43
43 44 if __name__ == '__main__':
45 # Don't call into msvcrt to set BytesIO to binary mode
46 util.setbinary = lambda fp: True
44 47 silenttestrunner.main(__name__)
General Comments 0
You need to be logged in to leave comments. Login now