##// END OF EJS Templates
Better fix for empty dropdown button alignment...
Better fix for empty dropdown button alignment Now an   character is inserted and bootstrap is left alone to deal with alignment.

File last commit:

r13443:56f9935e
r14359:9012e20a
Show More
test_ansi.py
84 lines | 3.5 KiB | text/x-python | PythonLexer
Jonathan Frederic
Added some filter tests
r11481 """
Module with tests for ansi filters
"""
#-----------------------------------------------------------------------------
# Copyright (c) 2013, the IPython Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
from IPython.utils.coloransi import TermColors
from ...tests.base import TestsBase
Jonathan Frederic
Explicit imports
r11928 from ..ansi import strip_ansi, ansi2html, ansi2latex
Jonathan Frederic
Added some filter tests
r11481
#-----------------------------------------------------------------------------
# Class
#-----------------------------------------------------------------------------
Jonathan Frederic
s/Test_/Test
r11494 class TestAnsi(TestsBase):
Jonathan Frederic
Added some filter tests
r11481 """Contains test functions for ansi.py"""
Jonathan Frederic
Filter names cleanup
r11685 def test_strip_ansi(self):
Jonathan Frederic
Shrink header comments
r11934 """strip_ansi test"""
Jonathan Frederic
Added some filter tests
r11481 correct_outputs = {
'%s%s%s' % (TermColors.Green, TermColors.White, TermColors.Red) : '',
'hello%s' % TermColors.Blue: 'hello',
'he%s%sllo' % (TermColors.Yellow, TermColors.Cyan) : 'hello',
'%shello' % TermColors.Blue : 'hello',
'{0}h{0}e{0}l{0}l{0}o{0}'.format(TermColors.Red) : 'hello',
'hel%slo' % TermColors.Green : 'hello',
'hello' : 'hello'}
for inval, outval in correct_outputs.items():
Thomas Kluyver
Remove ParametricTestCase from nbconvert tests
r12373 self._try_strip_ansi(inval, outval)
Jonathan Frederic
Added some filter tests
r11481
Jonathan Frederic
Filter names cleanup
r11685 def _try_strip_ansi(self, inval, outval):
Jonathan Frederic
Use IPython parameterized testing
r11936 self.assertEqual(outval, strip_ansi(inval))
Jonathan Frederic
Added some filter tests
r11481
def test_ansi2html(self):
Jonathan Frederic
Shrink header comments
r11934 """ansi2html test"""
Jonathan Frederic
Added some filter tests
r11481 correct_outputs = {
'%s' % (TermColors.Red) : '<span class="ansired"></span>',
'hello%s' % TermColors.Blue: 'hello<span class="ansiblue"></span>',
'he%s%sllo' % (TermColors.Green, TermColors.Cyan) : 'he<span class="ansigreen"></span><span class="ansicyan">llo</span>',
'%shello' % TermColors.Yellow : '<span class="ansiyellow">hello</span>',
'{0}h{0}e{0}l{0}l{0}o{0}'.format(TermColors.White) : '<span class="ansigrey">h</span><span class="ansigrey">e</span><span class="ansigrey">l</span><span class="ansigrey">l</span><span class="ansigrey">o</span><span class="ansigrey"></span>',
'hel%slo' % TermColors.Green : 'hel<span class="ansigreen">lo</span>',
'hello' : 'hello'}
for inval, outval in correct_outputs.items():
Thomas Kluyver
Remove ParametricTestCase from nbconvert tests
r12373 self._try_ansi2html(inval, outval)
Jonathan Frederic
Added some filter tests
r11481
def _try_ansi2html(self, inval, outval):
Jonathan Frederic
Use built in test comparison
r11909 self.fuzzy_compare(outval, ansi2html(inval))
Jonathan Frederic
Added some filter tests
r11481
def test_ansi2latex(self):
Jonathan Frederic
Shrink header comments
r11934 """ansi2latex test"""
Jonathan Frederic
Added some filter tests
r11481 correct_outputs = {
MinRK
test changes...
r13443 '%s' % (TermColors.Red) : r'{\color{red}}',
'hello%s' % TermColors.Blue: r'hello{\color{blue}}',
'he%s%sllo' % (TermColors.Green, TermColors.Cyan) : r'he{\color{green}}{\color{cyan}llo}',
'%shello' % TermColors.Yellow : r'{\color{yellow}hello}',
'{0}h{0}e{0}l{0}l{0}o{0}'.format(TermColors.White) : r'{\color{white}h}{\color{white}e}{\color{white}l}{\color{white}l}{\color{white}o}{\color{white}}',
'hel%slo' % TermColors.Green : r'hel{\color{green}lo}',
Jonathan Frederic
Added some filter tests
r11481 'hello' : 'hello'}
for inval, outval in correct_outputs.items():
Thomas Kluyver
Remove ParametricTestCase from nbconvert tests
r12373 self._try_ansi2latex(inval, outval)
Jonathan Frederic
Added some filter tests
r11481
def _try_ansi2latex(self, inval, outval):
Jonathan Frederic
Use built in test comparison
r11909 self.fuzzy_compare(outval, ansi2latex(inval), case_sensitive=True)