##// 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:

r15108:ab77a34b
r15754:d60e793e
Show More
test_utils.py
76 lines | 2.9 KiB | text/x-python | PythonLexer
MinRK
move url_[un]escape to utils from nbm
r13068 """Test HTML utils"""
#-----------------------------------------------------------------------------
# Copyright (C) 2013 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
#-----------------------------------------------------------------------------
Brian E. Granger
Creating and testing IPython.html.utils.is_hidden.
r15097 import os
MinRK
move url_[un]escape to utils from nbm
r13068 import nose.tools as nt
import IPython.testing.tools as tt
Brian E. Granger
Creating and testing IPython.html.utils.is_hidden.
r15097 from IPython.html.utils import url_escape, url_unescape, is_hidden
from IPython.utils.tempdir import TemporaryDirectory
MinRK
move url_[un]escape to utils from nbm
r13068
#-----------------------------------------------------------------------------
# Test functions
#-----------------------------------------------------------------------------
def test_help_output():
"""ipython notebook --help-all works"""
tt.help_all_output_test('notebook')
def test_url_escape():
# changes path or notebook name with special characters to url encoding
# these tests specifically encode paths with spaces
path = url_escape('/this is a test/for spaces/')
nt.assert_equal(path, '/this%20is%20a%20test/for%20spaces/')
path = url_escape('notebook with space.ipynb')
nt.assert_equal(path, 'notebook%20with%20space.ipynb')
path = url_escape('/path with a/notebook and space.ipynb')
nt.assert_equal(path, '/path%20with%20a/notebook%20and%20space.ipynb')
path = url_escape('/ !@$#%^&* / test %^ notebook @#$ name.ipynb')
nt.assert_equal(path,
'/%20%21%40%24%23%25%5E%26%2A%20/%20test%20%25%5E%20notebook%20%40%23%24%20name.ipynb')
def test_url_unescape():
# decodes a url string to a plain string
# these tests decode paths with spaces
path = url_unescape('/this%20is%20a%20test/for%20spaces/')
nt.assert_equal(path, '/this is a test/for spaces/')
path = url_unescape('notebook%20with%20space.ipynb')
nt.assert_equal(path, 'notebook with space.ipynb')
path = url_unescape('/path%20with%20a/notebook%20and%20space.ipynb')
nt.assert_equal(path, '/path with a/notebook and space.ipynb')
path = url_unescape(
'/%20%21%40%24%23%25%5E%26%2A%20/%20test%20%25%5E%20notebook%20%40%23%24%20name.ipynb')
nt.assert_equal(path, '/ !@$#%^&* / test %^ notebook @#$ name.ipynb')
Brian E. Granger
Creating and testing IPython.html.utils.is_hidden.
r15097 def test_is_hidden():
with TemporaryDirectory() as root:
subdir1 = os.path.join(root, 'subdir')
os.makedirs(subdir1)
Brian E. Granger
Small refactoring of is_hidden to take root as default kwarg.
r15108 nt.assert_equal(is_hidden(subdir1, root), False)
Brian E. Granger
Creating and testing IPython.html.utils.is_hidden.
r15097 subdir2 = os.path.join(root, '.subdir2')
os.makedirs(subdir2)
Brian E. Granger
Small refactoring of is_hidden to take root as default kwarg.
r15108 nt.assert_equal(is_hidden(subdir2, root), True)
Brian E. Granger
Creating and testing IPython.html.utils.is_hidden.
r15097 subdir34 = os.path.join(root, 'subdir3', '.subdir4')
os.makedirs(subdir34)
Brian E. Granger
Small refactoring of is_hidden to take root as default kwarg.
r15108 nt.assert_equal(is_hidden(subdir34, root), True)
nt.assert_equal(is_hidden(subdir34), True)