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

r13353:0ca701d5
r15754:d60e793e
Show More
test_json.py
72 lines | 2.3 KiB | text/x-python | PythonLexer
import pprint
from base64 import decodestring
from unittest import TestCase
from IPython.utils.py3compat import unicode_type
from ..nbjson import reads, writes
from .. import nbjson
from .nbexamples import nb0
from . import formattest
from .nbexamples import nb0
class TestJSON(formattest.NBFormatTest, TestCase):
nb0_ref = None
ext = 'ipynb'
mod = nbjson
def test_roundtrip_nosplit(self):
"""Ensure that multiline blobs are still readable"""
# ensures that notebooks written prior to splitlines change
# are still readable.
s = writes(nb0, split_lines=False)
self.assertEqual(nbjson.reads(s),nb0)
def test_roundtrip_split(self):
"""Ensure that splitting multiline blocks is safe"""
# This won't differ from test_roundtrip unless the default changes
s = writes(nb0, split_lines=True)
self.assertEqual(nbjson.reads(s),nb0)
def test_read_png(self):
"""PNG output data is b64 unicode"""
s = writes(nb0)
nb1 = nbjson.reads(s)
found_png = False
for cell in nb1.worksheets[0].cells:
if not 'outputs' in cell:
continue
for output in cell.outputs:
if 'png' in output:
found_png = True
pngdata = output['png']
self.assertEqual(type(pngdata), unicode_type)
# test that it is valid b64 data
b64bytes = pngdata.encode('ascii')
raw_bytes = decodestring(b64bytes)
assert found_png, "never found png output"
def test_read_jpeg(self):
"""JPEG output data is b64 unicode"""
s = writes(nb0)
nb1 = nbjson.reads(s)
found_jpeg = False
for cell in nb1.worksheets[0].cells:
if not 'outputs' in cell:
continue
for output in cell.outputs:
if 'jpeg' in output:
found_jpeg = True
jpegdata = output['jpeg']
self.assertEqual(type(jpegdata), unicode_type)
# test that it is valid b64 data
b64bytes = jpegdata.encode('ascii')
raw_bytes = decodestring(b64bytes)
assert found_jpeg, "never found jpeg output"