##// END OF EJS Templates
Moved more code to Strings utilities file
Moved more code to Strings utilities file

File last commit:

r10386:6416b524
r10434:855e7b47
Show More
test_simple.py
98 lines | 3.3 KiB | text/x-python | PythonLexer
Matthias BUSSONNIER
fix failing deprecated test
r9881 from nbconvert import converters, NbconvertApp
Matthias BUSSONNIER
Merge pull request 56 from dwf/nbconvert...
r8766 from converters.rst import ConverterRST
Paul Ivanov
refactored nbconvert, nosetest pass...
r6239 import nose.tools as nt
import os
import glob
Maximilian Albert
Clean up simple_test.py:...
r8742 import tempfile
import shutil
smithj1
Add unit test for ConvertRST.render_heading method...
r6259 from IPython.nbformat import current as nbformat
Paul Ivanov
refactored nbconvert, nosetest pass...
r6239
Anton I. Sipos
Fix main() function to use new object based converters, and add a test
r6252
Maximilian Albert
Clean up simple_test.py:...
r8742 class TestSimple(object):
def setUp(self):
"""
Create a new temporary directory and copy the input file
'test.ipynb' there.
"""
self.fname = 'test.ipynb'
self.basename = os.path.splitext(self.fname)[0]
self.wrkdir = tempfile.mkdtemp()
self.infile = os.path.join(self.wrkdir, self.fname)
shutil.copy(os.path.join('tests', self.fname), self.infile)
Anton I. Sipos
Fix main() function to use new object based converters, and add a test
r6252
Maximilian Albert
Clean up simple_test.py:...
r8742 def tearDown(self):
shutil.rmtree(self.wrkdir)
Anton I. Sipos
Add argument parsing, and ability to convert an HTML file from command line
r6261
Maximilian Albert
Clean up simple_test.py:...
r8742 def outfile_exists(self, fmt):
Maximilian Albert
Systematically test main() with all formats, not just 'rst' and 'html'.
r8743 extension = converters[fmt].extension
Matthias BUSSONNIER
fix tests
r9572 print("==out to ==>>",os.path.join(self.wrkdir,
self.basename + '.' + extension))
Maximilian Albert
Clean up simple_test.py:...
r8742 return os.path.exists(os.path.join(self.wrkdir,
Maximilian Albert
Systematically test main() with all formats, not just 'rst' and 'html'.
r8743 self.basename + '.' + extension))
Paul Ivanov
refactored nbconvert, nosetest pass...
r6239
Maximilian Albert
Clean up simple_test.py:...
r8742 def test_simple(self):
Matthias BUSSONNIER
fix tests
r9572 c = ConverterRST(infile=self.infile)
Maximilian Albert
Clean up simple_test.py:...
r8742 f = c.render()
nt.assert_true(f.endswith('.rst'), 'changed file extension to rst')
Paul Ivanov
refactored nbconvert, nosetest pass...
r6239
Maximilian Albert
Systematically test main() with all formats, not just 'rst' and 'html'.
r8743 def run_main(self, fmt):
"""
Run the 'main' method to convert the input file to the given
format and check that the expected output file exists.
"""
Matthias BUSSONNIER
fix tests
r9572 app = NbconvertApp.instance()
app.initialize()
app.extra_args = [self.infile]
app.fmt = fmt
app.start()
app.run()
Maximilian Albert
Systematically test main() with all formats, not just 'rst' and 'html'.
r8743 nt.assert_true(self.outfile_exists(fmt))
Maximilian Albert
Clean up simple_test.py:...
r8742 def test_main(self):
"""
Maximilian Albert
Systematically test main() with all formats, not just 'rst' and 'html'.
r8743 Test main entry point with all known formats.
Maximilian Albert
Clean up simple_test.py:...
r8742 """
damianavila
Added test_reveal in test_references and fixed test_simple.
r8925 # Exclude reveal from this test because:
# 1- AssertionError exception when there is not slideshow metadata.
# 2- outfile_exists method can not find properly the html file.
converters_copy = dict(converters)
del converters_copy['reveal']
for fmt in converters_copy:
Maximilian Albert
Systematically test main() with all formats, not just 'rst' and 'html'.
r8743 yield self.run_main, fmt
Anton I. Sipos
Add argument parsing, and ability to convert an HTML file from command line
r6261
Maximilian Albert
Clean up simple_test.py:...
r8742 def test_render_heading(self):
"""
Unit test for cell type "heading"
"""
# Generate and test heading cells level 1-6
for level in xrange(1, 7):
cell = {
'cell_type': 'heading',
'level': level,
'source': ['Test for heading type H{0}'.format(level)]
}
smithj1
Add unit test for ConvertRST.render_heading method...
r6259
Maximilian Albert
Clean up simple_test.py:...
r8742 # Convert cell dictionaries to NotebookNode
cell_nb = nbformat.NotebookNode(cell)
Anton I. Sipos
Add argument parsing, and ability to convert an HTML file from command line
r6261
Maximilian Albert
Clean up simple_test.py:...
r8742 # Make sure "source" attribute is uniconde not list.
# For some reason, creating a NotebookNode manually like
# this isn't converting source to a string like using
# the create-from-file routine.
if type(cell_nb.source) is list:
cell_nb.source = '\n'.join(cell_nb.source)
Anton I. Sipos
Add argument parsing, and ability to convert an HTML file from command line
r6261
Maximilian Albert
Clean up simple_test.py:...
r8742 # Render to rst
Matthias BUSSONNIER
fix tests
r9572 c = ConverterRST()
Maximilian Albert
Clean up simple_test.py:...
r8742 rst_list = c.render_heading(cell_nb)
Anton I. Sipos
Add argument parsing, and ability to convert an HTML file from command line
r6261
Maximilian Albert
Clean up simple_test.py:...
r8742 # render should return a list
nt.assert_true(isinstance(rst_list, list))
rst_str = "".join(rst_list)
# Confirm rst content
chk_str = "Test for heading type H{0}\n{1}\n".format(
level, c.heading_level[level] * 24)
nt.assert_equal(rst_str, chk_str)