##// END OF EJS Templates
Added utility function to build a proper resources dict
Jonathan Frederic -
Show More
@@ -14,10 +14,11 b' Module with utility functions for transformer tests'
14 # Imports
14 # Imports
15 #-----------------------------------------------------------------------------
15 #-----------------------------------------------------------------------------
16
16
17 from ...tests.base import TestsBase
18
19 from IPython.nbformat import current as nbformat
17 from IPython.nbformat import current as nbformat
20
18
19 from ...tests.base import TestsBase
20 from ...exporters.exporter import ResourcesDict
21
21 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
22 # Class
23 # Class
23 #-----------------------------------------------------------------------------
24 #-----------------------------------------------------------------------------
@@ -42,3 +43,11 b' class TransformerTestsBase(TestsBase):'
42 worksheets = [nbformat.new_worksheet(name="worksheet1", cells=cells)]
43 worksheets = [nbformat.new_worksheet(name="worksheet1", cells=cells)]
43
44
44 return nbformat.new_notebook(name="notebook1", worksheets=worksheets)
45 return nbformat.new_notebook(name="notebook1", worksheets=worksheets)
46
47
48 def build_resources(self):
49 """Build an empty resources dictionary."""
50
51 res = ResourcesDict()
52 res['metadata'] = ResourcesDict()
53 return res No newline at end of file
@@ -27,7 +27,7 b' class TestCoalesceStreams(TransformerTestsBase):'
27
27
28 def test_coalesce_streams(self):
28 def test_coalesce_streams(self):
29 """coalesce_streams transformer output test"""
29 """coalesce_streams transformer output test"""
30 nb, res = coalesce_streams(self.build_notebook(), {})
30 nb, res = coalesce_streams(self.build_notebook(), self.build_resources())
31 self.assertEqual(nb.worksheets[0].cells[0].outputs[0].text, "a")
31 self.assertEqual(nb.worksheets[0].cells[0].outputs[0].text, "a")
32 self.assertEqual(nb.worksheets[0].cells[0].outputs[1].output_type, "text")
32 self.assertEqual(nb.worksheets[0].cells[0].outputs[1].output_type, "text")
33 self.assertEqual(nb.worksheets[0].cells[0].outputs[2].text, "cd")
33 self.assertEqual(nb.worksheets[0].cells[0].outputs[2].text, "cd")
@@ -34,6 +34,6 b' class TestCSSHTMLHeader(TransformerTestsBase):'
34
34
35 def test_output(self):
35 def test_output(self):
36 """Test the output of the CSSHTMLHeaderTransformer"""
36 """Test the output of the CSSHTMLHeaderTransformer"""
37 nb, res = self.test_constructor()(self.build_notebook(), {})
37 nb, res = self.test_constructor()(self.build_notebook(), self.build_resources())
38 assert 'inlining' in res
38 assert 'inlining' in res
39 assert 'css' in res['inlining'] No newline at end of file
39 assert 'css' in res['inlining']
@@ -34,7 +34,7 b' class TestExtractOutput(TransformerTestsBase):'
34
34
35 def test_output(self):
35 def test_output(self):
36 """Test the output of the ExtractOutputTransformer"""
36 """Test the output of the ExtractOutputTransformer"""
37 nb, res = self.test_constructor()(self.build_notebook(), {})
37 nb, res = self.test_constructor()(self.build_notebook(), self.build_resources())
38
38
39 # Check if text was extracted.
39 # Check if text was extracted.
40 assert 'text_filename' in nb.worksheets[0].cells[0].outputs[1]
40 assert 'text_filename' in nb.worksheets[0].cells[0].outputs[1]
@@ -34,7 +34,7 b' class TestLatex(TransformerTestsBase):'
34
34
35 def test_output(self):
35 def test_output(self):
36 """Test the output of the LatexTransformer"""
36 """Test the output of the LatexTransformer"""
37 nb, res = self.test_constructor()(self.build_notebook(), {})
37 nb, res = self.test_constructor()(self.build_notebook(), self.build_resources())
38
38
39 # Make sure the code cell wasn't modified.
39 # Make sure the code cell wasn't modified.
40 self.assertEqual(nb.worksheets[0].cells[0].input, '$ e $')
40 self.assertEqual(nb.worksheets[0].cells[0].input, '$ e $')
General Comments 0
You need to be logged in to leave comments. Login now