##// END OF EJS Templates
Fully refactored subprocess handling on all platforms....
Fully refactored subprocess handling on all platforms. Now we have all process-related code in utils.process, which itself imports from platform-specific files as needed. On posix, we have reliable asynchronous delivery of stdout and stderr, and on win32 at least we have the basics that subprocess.py provides, since pexpect is not available. We also now support robust killing of subprocesses that may capture SIGINT: one SIGINT on our end is sent to the subprocess, but then we kill it, to prevent a rogue subprocess from hijacking the ipython console. Note that on posix, we now depend on pexpect, but we ship our own copy to users which we'll use if there's no system pexpect installed. UNC path handling for windows was implemented as a context manager called AvoidUNCPath.

File last commit:

r2783:3c79c2e7
r2908:06dcbd43
Show More
test_ansi_code_processor.py
52 lines | 1.9 KiB | text/x-python | PythonLexer
/ IPython / frontend / qt / console / tests / test_ansi_code_processor.py
# Standard library imports
import unittest
# Local imports
from IPython.frontend.qt.console.ansi_code_processor import AnsiCodeProcessor
class TestAnsiCodeProcessor(unittest.TestCase):
def setUp(self):
self.processor = AnsiCodeProcessor()
def testClear(self):
string = '\x1b[2J\x1b[K'
i = -1
for i, substring in enumerate(self.processor.split_string(string)):
if i == 0:
self.assertEquals(len(self.processor.actions), 1)
action = self.processor.actions[0]
self.assertEquals(action.kind, 'erase')
self.assertEquals(action.area, 'screen')
self.assertEquals(action.erase_to, 'all')
elif i == 1:
self.assertEquals(len(self.processor.actions), 1)
action = self.processor.actions[0]
self.assertEquals(action.kind, 'erase')
self.assertEquals(action.area, 'line')
self.assertEquals(action.erase_to, 'end')
else:
self.fail('Too many substrings.')
self.assertEquals(i, 1, 'Too few substrings.')
def testColors(self):
string = "first\x1b[34mblue\x1b[0mlast"
i = -1
for i, substring in enumerate(self.processor.split_string(string)):
if i == 0:
self.assertEquals(substring, 'first')
self.assertEquals(self.processor.foreground_color, None)
elif i == 1:
self.assertEquals(substring, 'blue')
self.assertEquals(self.processor.foreground_color, 4)
elif i == 2:
self.assertEquals(substring, 'last')
self.assertEquals(self.processor.foreground_color, None)
else:
self.fail('Too many substrings.')
self.assertEquals(i, 2, 'Too few substrings.')
if __name__ == '__main__':
unittest.main()