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

Method interpreter

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

Source from the content-addressed store, hash-verified

21class Test(unittest.TestCase):
22 @contextmanager
23 def interpreter(self):
24 self.original_stdout = sys.stdout
25 self.original_stderr = sys.stderr
26 sys.stdout = pydevd_io.IOBuf()
27 sys.stderr = pydevd_io.IOBuf()
28 try:
29 sys.stdout.encoding = sys.stdin.encoding
30 sys.stderr.encoding = sys.stdin.encoding
31 except AttributeError:
32 # In Python 3 encoding is not writable (whereas in Python 2 it doesn't exist).
33 pass
34
35 try:
36 client_port, _server_port = self.get_free_addresses()
37 client_thread = self.start_client_thread(client_port) # @UnusedVariable
38 import time
39
40 time.sleep(0.3) # let's give it some time to start the threads
41
42 from _pydev_bundle import pydev_localhost
43
44 interpreter = pydevconsole.InterpreterInterface(pydev_localhost.get_localhost(), client_port, threading.current_thread())
45 yield interpreter
46 except:
47 # if there's some error, print the output to the actual output.
48 self.original_stdout.write(sys.stdout.getvalue())
49 self.original_stderr.write(sys.stderr.getvalue())
50 raise
51 finally:
52 sys.stderr = self.original_stderr
53 sys.stdout = self.original_stdout
54
55 def test_console_hello(self):
56 with self.interpreter() as interpreter:

Callers 3

test_console_helloMethod · 0.95
test_console_asyncMethod · 0.95
test_console_requestsMethod · 0.95

Calls 4

get_free_addressesMethod · 0.95
start_client_threadMethod · 0.95
getvalueMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected