##// END OF EJS Templates
prerelease 3.0.0b1
prerelease 3.0.0b1

File last commit:

r18708:db31d216
r20281:ee6223ab
Show More
test_convert.py
72 lines | 1.9 KiB | text/x-python | PythonLexer
Nicholas Bollweg (Nick)
upgrading >v4 header cells to unicode...
r18700 # -*- coding: utf-8 -*-
MinRK
test and update conversion between v3 <-> v4
r18577 import copy
MinRK
remove heading cells in v4
r18596 import nose.tools as nt
MinRK
Add top-level IPython.nbformat API...
r18603 from IPython.nbformat import validate
MinRK
test and update conversion between v3 <-> v4
r18577 from .. import convert
from . import nbexamples
from IPython.nbformat.v3.tests import nbexamples as v3examples
MinRK
remove heading cells in v4
r18596 from IPython.nbformat import v3, v4
MinRK
test and update conversion between v3 <-> v4
r18577
def test_upgrade_notebook():
nb03 = copy.deepcopy(v3examples.nb0)
validate(nb03)
nb04 = convert.upgrade(nb03)
validate(nb04)
def test_downgrade_notebook():
nb04 = copy.deepcopy(nbexamples.nb0)
validate(nb04)
nb03 = convert.downgrade(nb04)
validate(nb03)
MinRK
remove heading cells in v4
r18596
def test_upgrade_heading():
v3h = v3.new_heading_cell
v4m = v4.new_markdown_cell
for v3cell, expected in [
(
v3h(source='foo', level=1),
v4m(source='# foo'),
),
(
v3h(source='foo\nbar\nmulti-line\n', level=4),
v4m(source='#### foo bar multi-line'),
),
Nicholas Bollweg (Nick)
upgrading >v4 header cells to unicode...
r18700 (
Min RK
fix unicode literal in v4.test_convert...
r18708 v3h(source=u'ünìcö∂e–cønvërsioñ', level=4),
Nicholas Bollweg (Nick)
more human-readable unicode chars in test
r18701 v4m(source=u'#### ünìcö∂e–cønvërsioñ'),
Nicholas Bollweg (Nick)
upgrading >v4 header cells to unicode...
r18700 ),
MinRK
remove heading cells in v4
r18596 ]:
upgraded = convert.upgrade_cell(v3cell)
nt.assert_equal(upgraded, expected)
def test_downgrade_heading():
v3h = v3.new_heading_cell
v4m = v4.new_markdown_cell
v3m = lambda source: v3.new_text_cell('markdown', source)
for v4cell, expected in [
(
v4m(source='# foo'),
v3h(source='foo', level=1),
),
(
v4m(source='#foo'),
v3h(source='foo', level=1),
),
(
v4m(source='#\tfoo'),
v3h(source='foo', level=1),
),
(
v4m(source='# \t foo'),
v3h(source='foo', level=1),
),
(
v4m(source='# foo\nbar'),
v3m(source='# foo\nbar'),
),
]:
downgraded = convert.downgrade_cell(v4cell)
nt.assert_equal(downgraded, expected)