Show More
@@ -0,0 +1,35 | |||
|
1 | """Test lexers module""" | |
|
2 | #----------------------------------------------------------------------------- | |
|
3 | # Copyright (C) 2014 The IPython Development Team | |
|
4 | # | |
|
5 | # Distributed under the terms of the BSD License. The full license is in | |
|
6 | # the file COPYING, distributed as part of this software. | |
|
7 | #----------------------------------------------------------------------------- | |
|
8 | ||
|
9 | #----------------------------------------------------------------------------- | |
|
10 | # Imports | |
|
11 | #----------------------------------------------------------------------------- | |
|
12 | from pygments.token import Token | |
|
13 | ||
|
14 | from IPython.nbconvert.tests.base import TestsBase | |
|
15 | from .. import lexers | |
|
16 | ||
|
17 | ||
|
18 | #----------------------------------------------------------------------------- | |
|
19 | # Classes and functions | |
|
20 | #----------------------------------------------------------------------------- | |
|
21 | class TestLexers(TestsBase): | |
|
22 | """Collection of lexers tests""" | |
|
23 | def setUp(self): | |
|
24 | self.lexer = lexers.IPythonLexer() | |
|
25 | ||
|
26 | def testIPythonLexer(self): | |
|
27 | fragment = '!echo $HOME\n' | |
|
28 | tokens = [ | |
|
29 | (Token.Operator, '!'), | |
|
30 | (Token.Name.Builtin, 'echo'), | |
|
31 | (Token.Text, ' '), | |
|
32 | (Token.Name.Variable, '$HOME'), | |
|
33 | (Token.Text, '\n'), | |
|
34 | ] | |
|
35 | self.assertEqual(tokens, list(self.lexer.get_tokens(fragment))) |
General Comments 0
You need to be logged in to leave comments.
Login now