MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / test_server

Method test_server

tests/test_pydevconsole.py:232–283  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

230 return port0, port1
231
232 def test_server(self):
233 self.original_stdout = sys.stdout
234 sys.stdout = pydevd_io.IOBuf()
235 try:
236 client_port, server_port = self.get_free_addresses()
237
238 class ServerThread(threading.Thread):
239 def __init__(self, client_port, server_port):
240 threading.Thread.__init__(self)
241 self.client_port = client_port
242 self.server_port = server_port
243
244 def run(self):
245 from _pydev_bundle import pydev_localhost
246
247 pydevconsole.start_server(pydev_localhost.get_localhost(), self.server_port, self.client_port)
248
249 server_thread = ServerThread(client_port, server_port)
250 server_thread.daemon = True
251 server_thread.start()
252
253 client_thread = self.start_client_thread(client_port) # @UnusedVariable
254
255 import time
256
257 time.sleep(0.3) # let's give it some time to start the threads
258 sys.stdout = pydevd_io.IOBuf()
259
260 from _pydev_bundle import pydev_localhost
261
262 server = xmlrpclib.Server("http://%s:%s" % (pydev_localhost.get_localhost(), server_port))
263 server.execLine("class Foo:")
264 server.execLine(" pass")
265 server.execLine("")
266 server.execLine("foo = Foo()")
267 server.execLine("a = input()")
268 server.execLine("print (a)")
269 initial = time.time()
270 while not client_thread.requested_input:
271 if time.time() - initial > 2:
272 raise AssertionError("Did not get the return asked before the timeout.")
273 time.sleep(0.1)
274
275 found = sys.stdout.getvalue()
276 while ["input_request"] != found.split():
277 found += sys.stdout.getvalue()
278 if time.time() - initial > 2:
279 break
280 time.sleep(0.1)
281 self.assertEqual(["input_request"], found.split())
282 finally:
283 sys.stdout = self.original_stdout

Callers

nothing calls this directly

Calls 6

get_free_addressesMethod · 0.95
start_client_threadMethod · 0.95
execLineMethod · 0.80
getvalueMethod · 0.80
ServerThreadClass · 0.70
startMethod · 0.45

Tested by

no test coverage detected