def child(kind): t = TestTerminal(stream=StringIO(), kind=kind) assert (t.clear == '') assert (t.move(1 == 2) == '') assert (t.move_x(1) == '') assert (t.bold() == '') assert (t.bold('', 'x', 'huh?') == '') assert (t.bold('', 9876) == '') assert (t.uhh(9876) == '') assert (t.clear('x') == 'x')
def child(kind): t = TestTerminal(stream=StringIO(), kind=kind) assert (t.clear == '') assert (t.move(1 == 2) == '') assert (t.move_x(1) == '') assert (t.bold() == '') assert (t.bold('', 'x', 'huh?') == '') assert (t.bold('', 9876) == '') assert (t.uhh(9876) == '') assert (t.clear('x') == 'x')
def child(kind): t = TestTerminal(kind=kind) # test simple sugar, if t.bold: expected_output = u''.join((t.bold, u'hi', t.normal)) else: expected_output = u'hi' assert t.bold(u'hi') == expected_output # Plain strs for Python 2.x if t.green: expected_output = u''.join((t.green, 'hi', t.normal)) else: expected_output = u'hi' assert t.green('hi') == expected_output # Test unicode if t.underline: expected_output = u''.join((t.underline, u'boö', t.normal)) else: expected_output = u'boö' assert (t.underline(u'boö') == expected_output) if t.subscript: expected_output = u''.join((t.subscript, u'[1]', t.normal)) else: expected_output = u'[1]' assert (t.subscript(u'[1]') == expected_output)
def child(kind): t = TestTerminal(kind=kind) # test simple sugar, if t.bold: expected_output = u''.join((t.bold, u'hi', t.normal)) else: expected_output = u'hi' assert t.bold(u'hi') == expected_output # Plain strs for Python 2.x if t.green: expected_output = u''.join((t.green, 'hi', t.normal)) else: expected_output = u'hi' assert t.green('hi') == expected_output # Test unicode if t.underline: expected_output = u''.join((t.underline, u'boö', t.normal)) else: expected_output = u'boö' assert (t.underline(u'boö') == expected_output) if t.subscript: expected_output = u''.join((t.subscript, u'[1]', t.normal)) else: expected_output = u'[1]' assert (t.subscript(u'[1]') == expected_output)
def child(kind): t = TestTerminal(kind=kind, stream=StringIO(), force_styling=False) assert (t.bold(u'hi') == u'hi') assert (t.green('hi') == u'hi') # Test non-ASCII chars, no longer really necessary: assert (t.bold_green(u'boö') == u'boö') assert (t.bold_underline_green_on_red('loo') == u'loo') assert (t.on_bright_red_bold_bright_green_underline('meh') == u'meh')
def child(kind): t = TestTerminal(kind=kind, stream=StringIO(), force_styling=False) assert (t.bold(u'hi') == u'hi') assert (t.green('hi') == u'hi') # Test non-ASCII chars, no longer really necessary: assert (t.bold_green(u'boö') == u'boö') assert (t.bold_underline_green_on_red('loo') == u'loo') assert (t.on_bright_red_bold_bright_green_underline('meh') == u'meh')
def child(kind): t = TestTerminal(kind=kind, force_styling=None) assert (t.save == '') assert (t.color(9) == '') assert (t.bold('oi') == 'oi')
def child(kind): t = TestTerminal(kind=kind) # Create a list of ascii characters, to be seperated # by word, to be zipped up with a cycling list of # terminal sequences. Then, compare the length of # each, the basic plain_text.__len__ vs. the Terminal # method length. They should be equal. plain_text = ('The softest things of the world ' 'Override the hardest things of the world ' 'That which has no substance ' 'Enters into that which has no openings') if t.bold: assert (t.length(t.bold) == 0) assert (t.length(t.bold('x')) == 1) assert (t.length(t.bold_red) == 0) assert (t.length(t.bold_red('x')) == 1) assert (t.strip(t.bold) == u'') assert (t.strip(t.bold(' x ')) == u'x') assert (t.strip(t.bold_red) == u'') assert (t.strip(t.bold_red(' x ')) == u'x') assert (t.strip_seqs(t.bold) == u'') assert (t.strip_seqs(t.bold(' x ')) == u' x ') assert (t.strip_seqs(t.bold_red) == u'') assert (t.strip_seqs(t.bold_red(' x ')) == u' x ') if t.underline: assert (t.length(t.underline) == 0) assert (t.length(t.underline('x')) == 1) assert (t.length(t.underline_red) == 0) assert (t.length(t.underline_red('x')) == 1) assert (t.strip(t.underline) == u'') assert (t.strip(t.underline(' x ')) == u'x') assert (t.strip(t.underline_red) == u'') assert (t.strip(t.underline_red(' x ')) == u'x') assert (t.strip_seqs(t.underline) == u'') assert (t.strip_seqs(t.underline(' x ')) == u' x ') assert (t.strip_seqs(t.underline_red) == u'') assert (t.strip_seqs(t.underline_red(' x ')) == u' x ') if t.reverse: assert (t.length(t.reverse) == 0) assert (t.length(t.reverse('x')) == 1) assert (t.length(t.reverse_red) == 0) assert (t.length(t.reverse_red('x')) == 1) assert (t.strip(t.reverse) == u'') assert (t.strip(t.reverse(' x ')) == u'x') assert (t.strip(t.reverse_red) == u'') assert (t.strip(t.reverse_red(' x ')) == u'x') assert (t.strip_seqs(t.reverse) == u'') assert (t.strip_seqs(t.reverse(' x ')) == u' x ') assert (t.strip_seqs(t.reverse_red) == u'') assert (t.strip_seqs(t.reverse_red(' x ')) == u' x ') if t.blink: assert (t.length(t.blink) == 0) assert (t.length(t.blink('x')) == 1) assert (t.length(t.blink_red) == 0) assert (t.length(t.blink_red('x')) == 1) assert (t.strip(t.blink) == u'') assert (t.strip(t.blink(' x ')) == u'x') assert (t.strip(t.blink_red) == u'') assert (t.strip(t.blink_red(' x ')) == u'x') assert (t.strip_seqs(t.blink) == u'') assert (t.strip_seqs(t.blink(' x ')) == u' x ') assert (t.strip_seqs(t.blink_red) == u'') assert (t.strip_seqs(t.blink_red(' x ')) == u' x ') if t.home: assert (t.length(t.home) == 0) assert (t.strip(t.home) == u'') if t.clear_eol: assert (t.length(t.clear_eol) == 0) assert (t.strip(t.clear_eol) == u'') if t.enter_fullscreen: assert (t.length(t.enter_fullscreen) == 0) assert (t.strip(t.enter_fullscreen) == u'') if t.exit_fullscreen: assert (t.length(t.exit_fullscreen) == 0) assert (t.strip(t.exit_fullscreen) == u'') # horizontally, we decide move_down and move_up are 0, assert (t.length(t.move_down) == 0) assert (t.length(t.move_down(2)) == 0) assert (t.length(t.move_up) == 0) assert (t.length(t.move_up(2)) == 0) # other things aren't so simple, somewhat edge cases, # moving backwards and forwards horizontally must be # accounted for as a "length", as <x><move right 10><y> # will result in a printed column length of 12 (even # though columns 2-11 are non-destructive space assert (t.length(u'x\b') == 0) assert (t.strip(u'x\b') == u'') # XXX why are some terminals width of 9 here ?? assert (t.length(u'\t') in (8, 9)) assert (t.strip(u'\t') == u'') assert (t.length(u'_' + t.move_left) == 0) if t.cub: assert (t.length((u'_' * 10) + t.cub(10)) == 0) assert (t.length(t.move_right) == 1) if t.cuf: assert (t.length(t.cuf(10)) == 10) # vertical spacing is unaccounted as a 'length' assert (t.length(t.move_up) == 0) assert (t.length(t.cuu(10)) == 0) assert (t.length(t.move_down) == 0) assert (t.length(t.cud(10)) == 0) # this is how manpages perform underlining, this is done # with the 'overstrike' capability of teletypes, and aparently # less(1), '123' -> '1\b_2\b_3\b_' text_wseqs = u''.join( itertools.chain(*zip(plain_text, itertools.cycle(['\b_'])))) assert (t.length(text_wseqs) == len(plain_text))
def child(kind): t = TestTerminal(kind=kind) # Create a list of ascii characters, to be separated # by word, to be zipped up with a cycling list of # terminal sequences. Then, compare the length of # each, the basic plain_text.__len__ vs. the Terminal # method length. They should be equal. plain_text = (u'The softest things of the world ' u'Override the hardest things of the world ' u'That which has no substance ' u'Enters into that which has no openings') if t.bold: assert (t.length(t.bold) == 0) assert (t.length(t.bold(u'x')) == 1) assert (t.length(t.bold_red) == 0) assert (t.length(t.bold_red(u'x')) == 1) assert (t.strip(t.bold) == u'') assert (t.rstrip(t.bold) == u'') assert (t.lstrip(t.bold) == u'') assert (t.strip(t.bold(u' x ')) == u'x') assert (t.strip(t.bold(u'z x q'), 'zq') == u' x ') assert (t.rstrip(t.bold(u' x ')) == u' x') assert (t.lstrip(t.bold(u' x ')) == u'x ') assert (t.strip(t.bold_red) == u'') assert (t.rstrip(t.bold_red) == u'') assert (t.lstrip(t.bold_red) == u'') assert (t.strip(t.bold_red(u' x ')) == u'x') assert (t.rstrip(t.bold_red(u' x ')) == u' x') assert (t.lstrip(t.bold_red(u' x ')) == u'x ') assert (t.strip_seqs(t.bold) == u'') assert (t.strip_seqs(t.bold(u' x ')) == u' x ') assert (t.strip_seqs(t.bold_red) == u'') assert (t.strip_seqs(t.bold_red(u' x ')) == u' x ') if t.underline: assert (t.length(t.underline) == 0) assert (t.length(t.underline(u'x')) == 1) assert (t.length(t.underline_red) == 0) assert (t.length(t.underline_red(u'x')) == 1) assert (t.strip(t.underline) == u'') assert (t.strip(t.underline(u' x ')) == u'x') assert (t.strip(t.underline_red) == u'') assert (t.strip(t.underline_red(u' x ')) == u'x') assert (t.rstrip(t.underline_red(u' x ')) == u' x') assert (t.lstrip(t.underline_red(u' x ')) == u'x ') assert (t.strip_seqs(t.underline) == u'') assert (t.strip_seqs(t.underline(u' x ')) == u' x ') assert (t.strip_seqs(t.underline_red) == u'') assert (t.strip_seqs(t.underline_red(u' x ')) == u' x ') if t.reverse: assert (t.length(t.reverse) == 0) assert (t.length(t.reverse(u'x')) == 1) assert (t.length(t.reverse_red) == 0) assert (t.length(t.reverse_red(u'x')) == 1) assert (t.strip(t.reverse) == u'') assert (t.strip(t.reverse(u' x ')) == u'x') assert (t.strip(t.reverse_red) == u'') assert (t.strip(t.reverse_red(u' x ')) == u'x') assert (t.rstrip(t.reverse_red(u' x ')) == u' x') assert (t.lstrip(t.reverse_red(u' x ')) == u'x ') assert (t.strip_seqs(t.reverse) == u'') assert (t.strip_seqs(t.reverse(u' x ')) == u' x ') assert (t.strip_seqs(t.reverse_red) == u'') assert (t.strip_seqs(t.reverse_red(u' x ')) == u' x ') if t.blink: assert (t.length(t.blink) == 0) assert (t.length(t.blink(u'x')) == 1) assert (t.length(t.blink_red) == 0) assert (t.length(t.blink_red(u'x')) == 1) assert (t.strip(t.blink) == u'') assert (t.strip(t.blink(u' x ')) == u'x') assert (t.strip(t.blink(u'z x q'), u'zq') == u' x ') assert (t.strip(t.blink_red) == u'') assert (t.strip(t.blink_red(u' x ')) == u'x') assert (t.strip_seqs(t.blink) == u'') assert (t.strip_seqs(t.blink(u' x ')) == u' x ') assert (t.strip_seqs(t.blink_red) == u'') assert (t.strip_seqs(t.blink_red(u' x ')) == u' x ') if t.home: assert (t.length(t.home) == 0) assert (t.strip(t.home) == u'') if t.clear_eol: assert (t.length(t.clear_eol) == 0) assert (t.strip(t.clear_eol) == u'') if t.enter_fullscreen: assert (t.length(t.enter_fullscreen) == 0) assert (t.strip(t.enter_fullscreen) == u'') if t.exit_fullscreen: assert (t.length(t.exit_fullscreen) == 0) assert (t.strip(t.exit_fullscreen) == u'') # horizontally, we decide move_down and move_up are 0, assert (t.length(t.move_down) == 0) assert (t.length(t.move_down(2)) == 0) assert (t.length(t.move_up) == 0) assert (t.length(t.move_up(2)) == 0) # other things aren't so simple, somewhat edge cases, # moving backwards and forwards horizontally must be # accounted for as a "length", as <x><move right 10><y> # will result in a printed column length of 12 (even # though columns 2-11 are non-destructive space assert (t.length(u'x\b') == 0) assert (t.strip(u'x\b') == u'') # XXX why are some terminals width of 9 here ?? assert (t.length(u'\t') in (8, 9)) assert (t.strip(u'\t') == u'') assert (t.length(u'_' + t.move_left) == 0) if t.cub: assert (t.length((u'_' * 10) + t.cub(10)) == 0) assert (t.length(t.move_right) == 1) if t.cuf: assert (t.length(t.cuf(10)) == 10) # vertical spacing is unaccounted as a 'length' assert (t.length(t.move_up) == 0) assert (t.length(t.cuu(10)) == 0) assert (t.length(t.move_down) == 0) assert (t.length(t.cud(10)) == 0) # this is how manpages perform underlining, this is done # with the 'overstrike' capability of teletypes, and aparently # less(1), '123' -> '1\b_2\b_3\b_' text_wseqs = u''.join(itertools.chain( *zip(plain_text, itertools.cycle(['\b_'])))) assert (t.length(text_wseqs) == len(plain_text))
def child(kind): t = TestTerminal(kind=kind, force_styling=None) assert t.save == "" assert t.color(9) == "" assert t.bold("oi") == "oi"