##// END OF EJS Templates
fix latex_transformer and add test
fix latex_transformer and add test

File last commit:

r9572:1f168443
r9888:b84afae9
Show More
test_nbconverter.py
33 lines | 1.0 KiB | text/x-python | PythonLexer
/ tests / test_nbconverter.py
Matthias BUSSONNIER
Merge pull request 56 from dwf/nbconvert...
r8766 from converters import ConverterNotebook
Jonathan Taylor
overriding DocInherit due to recursion depth errors
r7366 import nose.tools as nt
David Warde-Farley
Make tests more filesystem-friendly
r8719 import os
import json
import shutil
import tempfile
Jonathan Taylor
overriding DocInherit due to recursion depth errors
r7366
David Warde-Farley
Make tests more filesystem-friendly
r8719
# name = os.path.join(os.path.dirname(os.path.abspath(__file__), test.ipynb')
Jonathan Taylor
overriding DocInherit due to recursion depth errors
r7366 outbase1 = 'newtest1'
David Warde-Farley
Make tests more filesystem-friendly
r8719 outbase2 = 'test' # will output to ./test.ipynb
Jonathan Taylor
overriding DocInherit due to recursion depth errors
r7366
def test_roundtrip():
David Warde-Farley
Make tests more filesystem-friendly
r8719 directory = tempfile.mkdtemp()
out1 = os.path.join(directory, outbase1)
out2 = os.path.join(directory, outbase2)
fname = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'test.ipynb')
Matthias BUSSONNIER
fix tests
r9572 converter = ConverterNotebook(infile=fname, outbase=out1)
Jonathan Taylor
overriding DocInherit due to recursion depth errors
r7366 converter.render()
Matthias BUSSONNIER
fix tests
r9572 converter2 = ConverterNotebook(infile=out1 + '.ipynb', outbase=out2)
Jonathan Taylor
overriding DocInherit due to recursion depth errors
r7366 converter2.render()
David Warde-Farley
Make tests more filesystem-friendly
r8719 with open(out1 + '.ipynb', 'rb') as f:
s1 = f.read()
with open(out2 + '.ipynb', 'rb') as f:
s2 = f.read()
Jonathan Taylor
overriding DocInherit due to recursion depth errors
r7366 nt.assert_true(s1.replace(outbase1, outbase2) == s2)
David Warde-Farley
Make tests more filesystem-friendly
r8719 shutil.rmtree(directory)
Jonathan Taylor
testing roundtrip of test.ipynb file after passing through json.dump/json.load
r7369 s0 = json.dumps(json.load(file(fname)), indent=1, sort_keys=True)
nt.assert_true(s0 == s2)