##// END OF EJS Templates
refactor to improve cell switching in edit mode...
refactor to improve cell switching in edit mode This code was repeated in both CodeCell and TextCell, both of which are extensions of Cell, so this just unifies the logic in Cell. TextCell had logic here to check if the cell was rendered or not, but I don't believe it is possible to end up triggering such a code path. (Should that be required, I can always just add back these methods to TextCell, performing the .rendered==True check, and calling the Cell prior to this, code mirror at_top would only return true on if the cursor was at the first character of the top line. Now, pressing up arrow on any character on the top line will take you to the cell above. The same applies for the bottom line. Pressing down arrow would only go to the next cell if the cursor was at a location *after* the last character (something that is only possible to achieve in vim mode if the last line is empty, for example). Now, down arrow on any character of the last line will go to the next cell.

File last commit:

r13505:516dd69f
r15754:d60e793e
Show More
test_highlight.py
88 lines | 2.6 KiB | text/x-python | PythonLexer
Jonathan Frederic
Added some filter tests
r11481 """
Module with tests for Highlight
"""
#-----------------------------------------------------------------------------
# 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 ...tests.base import TestsBase
Matthias BUSSONNIER
LaTeX highlighter configurable, + tests
r13505 from ..highlight import Highlight2Html, Highlight2Latex
from IPython.config import Config
import xml
Jonathan Frederic
Added some filter tests
r11481
#-----------------------------------------------------------------------------
# Class
#-----------------------------------------------------------------------------
Matthias BUSSONNIER
fix test
r13324 highlight2html = Highlight2Html()
Matthias BUSSONNIER
LaTeX highlighter configurable, + tests
r13505 highlight2latex = Highlight2Latex()
c = Config()
c.Highlight2Html.default_language='ruby'
highlight2html_ruby = Highlight2Html(config=c)
Matthias BUSSONNIER
fix test
r13324
Jonathan Frederic
s/Test_/Test
r11494 class TestHighlight(TestsBase):
Jonathan Frederic
Added some filter tests
r11481 """Contains test functions for highlight.py"""
Jonathan Frederic
Added highlight tests
r11906 #Hello world test, magics test, blank string test
tests = [
Jonathan Frederic
Instead of fuzzy compare, check for tokens in output
r11914 """
#Hello World Example
def say(text):
print(text)
Jonathan Frederic
Added some filter tests
r11481
Matthias BUSSONNIER
LaTeX highlighter configurable, + tests
r13505 end
Jonathan Frederic
Instead of fuzzy compare, check for tokens in output
r11914 say('Hello World!')
""",
"""
%%pylab
plot(x,y, 'r')
Jonathan Frederic
Remove null tests
r11918 """
Jonathan Frederic
Instead of fuzzy compare, check for tokens in output
r11914 ]
Jonathan Frederic
Added some filter tests
r11481
Jonathan Frederic
Instead of fuzzy compare, check for tokens in output
r11914 tokens = [
['Hello World Example', 'say', 'text', 'print', 'def'],
['pylab', 'plot']]
Jonathan Frederic
Added some filter tests
r11481
Jonathan Frederic
Added highlight tests
r11906
def test_highlight2html(self):
Jonathan Frederic
Shrink header comments
r11934 """highlight2html test"""
Jonathan Frederic
Added highlight tests
r11906 for index, test in enumerate(self.tests):
Thomas Kluyver
Remove ParametricTestCase from nbconvert tests
r12373 self._try_highlight(highlight2html, test, self.tokens[index])
Jonathan Frederic
Added highlight tests
r11906
def test_highlight2latex(self):
Jonathan Frederic
Shrink header comments
r11934 """highlight2latex test"""
Jonathan Frederic
Added highlight tests
r11906 for index, test in enumerate(self.tests):
Thomas Kluyver
Remove ParametricTestCase from nbconvert tests
r12373 self._try_highlight(highlight2latex, test, self.tokens[index])
Jonathan Frederic
Added highlight tests
r11906
Matthias BUSSONNIER
LaTeX highlighter configurable, + tests
r13505 def test_parse_html_many_lang(self):
ht = highlight2html(self.tests[0])
rb = highlight2html_ruby(self.tests[0])
for lang,tkns in [
( ht, ('def','print') ),
( rb, ('def','end' ) )
]:
root = xml.etree.ElementTree.fromstring(lang)
assert self._extract_tokens(root,'k') == set(tkns)
def _extract_tokens(self, root, cls):
return set(map(lambda x:x.text,root.findall(".//*[@class='"+cls+"']")))
Jonathan Frederic
Added highlight tests
r11906
Jonathan Frederic
Instead of fuzzy compare, check for tokens in output
r11914 def _try_highlight(self, method, test, tokens):
Jonathan Frederic
Shrink header comments
r11934 """Try highlighting source, look for key tokens"""
Jonathan Frederic
Instead of fuzzy compare, check for tokens in output
r11914 results = method(test)
for token in tokens:
assert token in results