##// END OF EJS Templates
disallow no-prefix `ipython foo=bar` argument style....
disallow no-prefix `ipython foo=bar` argument style. This style is in rc1, but will be removed in rc2. Since they don't match any flag pattern, rc1-style arguments will be interpreted by IPython as files to be run. So `ipython gui=foo -i` will exec gui=foo, and pass '-i' to gui=foo. Presumably this file won't exist, so there will be an error: Error in executing file in user namespace: gui=foo Assignments *must* have two leading '-', as in: ipython --foo=bar all flags (non-assignments) can be specified with one or two leading '-', as in: ipython -i --pylab -pdb --pprint script.py or ipython --i -pylab --pdb -pprint script.py but help only reports two-leading, as single-leading options will likely be removed on moving to argparse, where they will be replaced by single-letter aliases. The common remaining invalid option will be: ipython -foo=bar and a suggestion for 'did you mean --foo=bar'? will be presented in these cases.

File last commit:

r3367:dd6217a5
r4197:368e365a
Show More
test_ansi_code_processor.py
107 lines | 4.2 KiB | text/x-python | PythonLexer
/ IPython / frontend / qt / console / tests / test_ansi_code_processor.py
epatters
* Moved AnsiCodeProcessor to separate file, refactored its API, and added unit tests....
r2716 # 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()
epatters
Added 256-color support to Qt console escape sequence processing.
r3367 def test_clear(self):
""" Do control sequences for clearing the console work?
"""
epatters
Added support for ANSI erase codes. Clearing the console via ANSI escape sequences is now supported.
r2783 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]
epatters
Added support for scroll sequences and form feeds to AnsiCodeProcessor....
r2998 self.assertEquals(action.action, 'erase')
epatters
Added support for ANSI erase codes. Clearing the console via ANSI escape sequences is now supported.
r2783 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]
epatters
Added support for scroll sequences and form feeds to AnsiCodeProcessor....
r2998 self.assertEquals(action.action, 'erase')
epatters
Added support for ANSI erase codes. Clearing the console via ANSI escape sequences is now supported.
r2783 self.assertEquals(action.area, 'line')
self.assertEquals(action.erase_to, 'end')
else:
self.fail('Too many substrings.')
self.assertEquals(i, 1, 'Too few substrings.')
epatters
Added 256-color support to Qt console escape sequence processing.
r3367 def test_colors(self):
""" Do basic controls sequences for colors work?
"""
string = 'first\x1b[34mblue\x1b[0mlast'
epatters
* Moved AnsiCodeProcessor to separate file, refactored its API, and added unit tests....
r2716 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:
epatters
Added support for ANSI erase codes. Clearing the console via ANSI escape sequences is now supported.
r2783 self.fail('Too many substrings.')
self.assertEquals(i, 2, 'Too few substrings.')
epatters
* Moved AnsiCodeProcessor to separate file, refactored its API, and added unit tests....
r2716
epatters
Added 256-color support to Qt console escape sequence processing.
r3367 def test_colors_xterm(self):
""" Do xterm-specific control sequences for colors work?
"""
string = '\x1b]4;20;rgb:ff/ff/ff\x1b' \
'\x1b]4;25;rgbi:1.0/1.0/1.0\x1b'
substrings = list(self.processor.split_string(string))
desired = { 20 : (255, 255, 255),
25 : (255, 255, 255) }
self.assertEquals(self.processor.color_map, desired)
string = '\x1b[38;5;20m\x1b[48;5;25m'
substrings = list(self.processor.split_string(string))
self.assertEquals(self.processor.foreground_color, 20)
self.assertEquals(self.processor.background_color, 25)
def test_scroll(self):
""" Do control sequences for scrolling the buffer work?
"""
epatters
Added support for scroll sequences and form feeds to AnsiCodeProcessor....
r2998 string = '\x1b[5S\x1b[T'
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.action, 'scroll')
self.assertEquals(action.dir, 'up')
self.assertEquals(action.unit, 'line')
self.assertEquals(action.count, 5)
elif i == 1:
self.assertEquals(len(self.processor.actions), 1)
action = self.processor.actions[0]
self.assertEquals(action.action, 'scroll')
self.assertEquals(action.dir, 'down')
self.assertEquals(action.unit, 'line')
self.assertEquals(action.count, 1)
else:
self.fail('Too many substrings.')
self.assertEquals(i, 1, 'Too few substrings.')
epatters
Added 256-color support to Qt console escape sequence processing.
r3367 def test_specials(self):
""" Are special characters processed correctly?
"""
epatters
Added support for scroll sequences and form feeds to AnsiCodeProcessor....
r2998 string = '\f' # form feed
self.assertEquals(list(self.processor.split_string(string)), [''])
self.assertEquals(len(self.processor.actions), 1)
action = self.processor.actions[0]
self.assertEquals(action.action, 'scroll')
self.assertEquals(action.dir, 'down')
self.assertEquals(action.unit, 'page')
self.assertEquals(action.count, 1)
epatters
* Moved AnsiCodeProcessor to separate file, refactored its API, and added unit tests....
r2716
if __name__ == '__main__':
unittest.main()