(self)
| 21 | class 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: |
no test coverage detected