##// END OF EJS Templates
add three tests for cell magic syntax highlighting
Jörg Dietrich -
Show More
@@ -127,3 +127,50 b' class TestLexers(TestCase):'
127 (Token.Text, '\n'),
127 (Token.Text, '\n'),
128 ]
128 ]
129 self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
129 self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
130
131 fragment = '%%writefile -a foo.py\nif a == b:\n pass'
132 tokens = [
133 (Token.Operator, '%%writefile'),
134 (Token.Text, ' -a foo.py\n'),
135 (Token.Keyword, 'if'),
136 (Token.Text, ' '),
137 (Token.Name, 'a'),
138 (Token.Text, ' '),
139 (Token.Operator, '=='),
140 (Token.Text, ' '),
141 (Token.Name, 'b'),
142 (Token.Punctuation, ':'),
143 (Token.Text, '\n'),
144 (Token.Text, ' '),
145 (Token.Keyword, 'pass'),
146 (Token.Text, '\n'),
147 ]
148 self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
149
150 fragment = '%%timeit\nmath.sin(0)'
151 tokens = [
152 (Token.Operator, '%%timeit\n'),
153 (Token.Name, 'math'),
154 (Token.Operator, '.'),
155 (Token.Name, 'sin'),
156 (Token.Punctuation, '('),
157 (Token.Literal.Number.Integer, '0'),
158 (Token.Punctuation, ')'),
159 (Token.Text, '\n'),
160 ]
161
162 fragment = '%%HTML\n<div>foo</div>'
163 tokens = [
164 (Token.Operator, '%%HTML'),
165 (Token.Text, '\n'),
166 (Token.Punctuation, '<'),
167 (Token.Name.Tag, 'div'),
168 (Token.Punctuation, '>'),
169 (Token.Text, 'foo'),
170 (Token.Punctuation, '<'),
171 (Token.Punctuation, '/'),
172 (Token.Name.Tag, 'div'),
173 (Token.Punctuation, '>'),
174 (Token.Text, '\n'),
175 ]
176 self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
General Comments 0
You need to be logged in to leave comments. Login now