From 2aec6283eb8f127a45e1e40d10e332128972a88a 2013-08-12 22:43:06 From: Jonathan Frederic Date: 2013-08-12 22:43:06 Subject: [PATCH] Fixed, don't check using in since resources is a default dict. --- diff --git a/IPython/nbconvert/exporters/tests/test_exporter.py b/IPython/nbconvert/exporters/tests/test_exporter.py index c65f150..2858dad 100644 --- a/IPython/nbconvert/exporters/tests/test_exporter.py +++ b/IPython/nbconvert/exporters/tests/test_exporter.py @@ -53,7 +53,7 @@ class TestExporter(ExportersTestsBase): exporter = self._make_exporter(config=config) (output, resources) = exporter.from_filename(self._get_notebook()) assert resources is not None - assert 'outputs' in resources + assert isinstance(resources['outputs'], dict) assert len(resources['outputs']) > 0 @@ -65,7 +65,6 @@ class TestExporter(ExportersTestsBase): exporter = self._make_exporter(config=config) (output, resources) = exporter.from_filename(self._get_notebook()) assert resources is not None - assert 'cheese' in resources assert resources['cheese'] == 'real' @@ -77,7 +76,6 @@ class TestExporter(ExportersTestsBase): exporter = self._make_exporter(config=config) (output, resources) = exporter.from_filename(self._get_notebook()) assert resources is not None - assert 'cheese' in resources assert resources['cheese'] == 'real' @@ -89,7 +87,6 @@ class TestExporter(ExportersTestsBase): exporter = self._make_exporter(config=config) (output, resources) = exporter.from_filename(self._get_notebook()) assert resources is not None - assert 'cheese' in resources assert resources['cheese'] == 'real' @@ -101,7 +98,6 @@ class TestExporter(ExportersTestsBase): exporter.register_transformer(CheeseTransformer, enabled=True) (output, resources) = exporter.from_filename(self._get_notebook()) assert resources is not None - assert 'cheese' in resources assert resources['cheese'] == 'real' diff --git a/IPython/nbconvert/transformers/extractoutput.py b/IPython/nbconvert/transformers/extractoutput.py index ecd6783..d6a83ae 100755 --- a/IPython/nbconvert/transformers/extractoutput.py +++ b/IPython/nbconvert/transformers/extractoutput.py @@ -57,7 +57,7 @@ class ExtractOutputTransformer(Transformer): output_files_dir = resources.get('output_files_dir', None) #Make sure outputs key exists - if not 'outputs' in resources: + if not isinstance(resources['outputs'], dict): resources['outputs'] = {} #Loop through all of the outputs in the cell diff --git a/IPython/nbconvert/transformers/revealhelp.py b/IPython/nbconvert/transformers/revealhelp.py index 96d69f1..7e79f1f 100755 --- a/IPython/nbconvert/transformers/revealhelp.py +++ b/IPython/nbconvert/transformers/revealhelp.py @@ -54,7 +54,7 @@ class RevealHelpTransformer(Transformer): worksheet.cells[index - 1].metadata.slide_helper = 'subslide_end' - if 'reveal' not in resources: + if not isinstance(resources['reveal'], dict): resources['reveal'] = {} resources['reveal']['url_prefix'] = self.url_prefix diff --git a/IPython/nbconvert/transformers/sphinx.py b/IPython/nbconvert/transformers/sphinx.py index 8c4fa7c..636d9f6 100755 --- a/IPython/nbconvert/transformers/sphinx.py +++ b/IPython/nbconvert/transformers/sphinx.py @@ -127,7 +127,7 @@ class SphinxTransformer(Transformer): # TODO: Add versatile method of additional notebook metadata. Include # handling of multiple files. For now use a temporay namespace, # '_draft' to signify that this needs to change. - if not "sphinx" in resources: + if not isinstance(resources["sphinx"], dict): resources["sphinx"] = {} if self.interactive: diff --git a/IPython/nbconvert/transformers/tests/test_csshtmlheader.py b/IPython/nbconvert/transformers/tests/test_csshtmlheader.py index 709e3af..7b41a5e 100644 --- a/IPython/nbconvert/transformers/tests/test_csshtmlheader.py +++ b/IPython/nbconvert/transformers/tests/test_csshtmlheader.py @@ -44,5 +44,4 @@ class TestCSSHTMLHeader(TransformerTestsBase): res = self.build_resources() transformer = self.build_transformer() nb, res = transformer(nb, res) - assert 'inlining' in res assert 'css' in res['inlining'] \ No newline at end of file diff --git a/IPython/nbconvert/transformers/tests/test_extractoutput.py b/IPython/nbconvert/transformers/tests/test_extractoutput.py index 21f93e6..1da1988 100644 --- a/IPython/nbconvert/transformers/tests/test_extractoutput.py +++ b/IPython/nbconvert/transformers/tests/test_extractoutput.py @@ -53,9 +53,6 @@ class TestExtractOutput(TransformerTestsBase): assert 'png_filename' in nb.worksheets[0].cells[0].outputs[6] png_filename = nb.worksheets[0].cells[0].outputs[6]['png_filename'] - # Make sure an entry to the resources was added. - assert 'outputs' in res - # Verify text output assert text_filename in res['outputs'] self.assertEqual(res['outputs'][text_filename], b'b') diff --git a/IPython/nbconvert/transformers/tests/test_sphinx.py b/IPython/nbconvert/transformers/tests/test_sphinx.py index 610c246..6c65578 100644 --- a/IPython/nbconvert/transformers/tests/test_sphinx.py +++ b/IPython/nbconvert/transformers/tests/test_sphinx.py @@ -45,7 +45,6 @@ class TestSphinx(TransformerTestsBase): res = self.build_resources() transformer = self.build_transformer() nb, res = transformer(nb, res) - assert 'sphinx' in res assert "author" in res['sphinx'] assert "version" in res['sphinx'] assert "release" in res['sphinx'] diff --git a/IPython/nbconvert/writers/debug.py b/IPython/nbconvert/writers/debug.py index 7a93ace..5c5ea43 100644 --- a/IPython/nbconvert/writers/debug.py +++ b/IPython/nbconvert/writers/debug.py @@ -33,7 +33,7 @@ class DebugWriter(WriterBase): See base for more... """ - if 'outputs' in resources: + if isinstance(resources['outputs'], dict): print("outputs extracted from %s" % notebook_name) print('-' * 80) pprint(resources['outputs'], indent=2, width=70)