From 513f4ea17774b1f6253d34f57767943f3d3aa6ca 2015-01-23 20:08:33 From: Lev Abalkin Date: 2015-01-23 20:08:33 Subject: [PATCH] Added lexers test for issue #7548. --- diff --git a/IPython/nbconvert/utils/tests/test_lexers.py b/IPython/nbconvert/utils/tests/test_lexers.py new file mode 100644 index 0000000..d2371c1 --- /dev/null +++ b/IPython/nbconvert/utils/tests/test_lexers.py @@ -0,0 +1,35 @@ +"""Test lexers module""" +#----------------------------------------------------------------------------- +# Copyright (C) 2014 The IPython Development Team +# +# Distributed under the terms of the BSD License. The full license is in +# the file COPYING, distributed as part of this software. +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Imports +#----------------------------------------------------------------------------- +from pygments.token import Token + +from IPython.nbconvert.tests.base import TestsBase +from .. import lexers + + +#----------------------------------------------------------------------------- +# Classes and functions +#----------------------------------------------------------------------------- +class TestLexers(TestsBase): + """Collection of lexers tests""" + def setUp(self): + self.lexer = lexers.IPythonLexer() + + def testIPythonLexer(self): + fragment = '!echo $HOME\n' + tokens = [ + (Token.Operator, '!'), + (Token.Name.Builtin, 'echo'), + (Token.Text, ' '), + (Token.Name.Variable, '$HOME'), + (Token.Text, '\n'), + ] + self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))