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