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

Method test_server

tests/test_check_pydevconsole.py:73–121  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

71 return [socket_name[1] for socket_name in socket_names]
72
73 def test_server(self):
74 # Just making sure that the singleton is created in this thread.
75 from _pydev_bundle.pydev_ipython_console_011 import get_pydev_frontend
76
77 get_pydev_frontend(get_localhost(), 0)
78
79 client_port, server_port = self.get_free_addresses()
80
81 class ServerThread(threading.Thread):
82 def __init__(self, client_port, server_port):
83 threading.Thread.__init__(self)
84 self.client_port = client_port
85 self.server_port = server_port
86
87 def run(self):
88 from _pydev_bundle import pydev_localhost
89
90 print("Starting server with:", pydev_localhost.get_localhost(), self.server_port, self.client_port)
91 pydevconsole.start_server(pydev_localhost.get_localhost(), self.server_port, self.client_port)
92
93 server_thread = ServerThread(client_port, server_port)
94 server_thread.daemon = True
95 server_thread.start()
96
97 client_thread = self.start_client_thread(client_port) # @UnusedVariable
98
99 try:
100 import time
101
102 time.sleep(0.3) # let's give it some time to start the threads
103
104 from _pydev_bundle import pydev_localhost
105
106 server = xmlrpclib.Server("http://%s:%s" % (pydev_localhost.get_localhost(), server_port))
107 server.execLine("import sys; print('Running with: %s %s' % (sys.executable or sys.platform, sys.version))")
108 server.execLine("class Foo:")
109 server.execLine(" pass")
110 server.execLine("")
111 server.execLine("foo = Foo()")
112 server.execLine("a = %s()" % raw_input_name)
113 initial = time.time()
114 while not client_thread.requested_input:
115 if time.time() - initial > 2:
116 raise AssertionError("Did not get the return asked before the timeout.")
117 time.sleep(0.1)
118 frame_xml = server.getFrame()
119 self.assertTrue("RequestInput" in frame_xml, "Did not fid RequestInput in:\n%s" % (frame_xml,))
120 finally:
121 client_thread.shutdown()

Callers

nothing calls this directly

Calls 9

get_free_addressesMethod · 0.95
start_client_threadMethod · 0.95
get_pydev_frontendFunction · 0.90
get_localhostFunction · 0.90
execLineMethod · 0.80
getFrameMethod · 0.80
ServerThreadClass · 0.70
startMethod · 0.45
shutdownMethod · 0.45

Tested by

no test coverage detected