From 9dc7b4a630f7adf945259ec552f67589d99c2ac0 2014-04-07 18:19:00 From: MinRK Date: 2014-04-07 18:19:00 Subject: [PATCH] output_type should not be optional in new_output and fix bug that this would have revealed --- diff --git a/IPython/html/nbconvert/tests/test_nbconvert_handlers.py b/IPython/html/nbconvert/tests/test_nbconvert_handlers.py index b612b9c..6916f1f 100644 --- a/IPython/html/nbconvert/tests/test_nbconvert_handlers.py +++ b/IPython/html/nbconvert/tests/test_nbconvert_handlers.py @@ -58,7 +58,7 @@ class APITest(NotebookTestBase): nb.worksheets = [ws] ws.cells.append(new_heading_cell(u'Created by test ³')) cc1 = new_code_cell(input=u'print(2*6)') - cc1.outputs.append(new_output(output_text=u'12')) + cc1.outputs.append(new_output(output_text=u'12', output_type='stream')) cc1.outputs.append(new_output(output_png=png_green_pixel, output_type='pyout')) ws.cells.append(cc1) diff --git a/IPython/nbformat/v3/nbbase.py b/IPython/nbformat/v3/nbbase.py index c35d711..fcd86f6 100644 --- a/IPython/nbformat/v3/nbbase.py +++ b/IPython/nbformat/v3/nbbase.py @@ -4,22 +4,10 @@ The Python representation of a notebook is a nested structure of dictionary subclasses that support attribute access (IPython.utils.ipstruct.Struct). The functions in this module are merely helpers to build the structs in the right form. - -Authors: - -* Brian Granger """ -#----------------------------------------------------------------------------- -# Copyright (C) 2008-2011 The IPython Development Team -# -# Distributed under the terms of the BSD License. The full license is in -# the file COPYING, distributed as part of this software. -#----------------------------------------------------------------------------- - -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. import pprint import uuid @@ -51,15 +39,14 @@ def from_dict(d): return d -def new_output(output_type=None, output_text=None, output_png=None, +def new_output(output_type, output_text=None, output_png=None, output_html=None, output_svg=None, output_latex=None, output_json=None, output_javascript=None, output_jpeg=None, prompt_number=None, ename=None, evalue=None, traceback=None, stream=None, metadata=None): """Create a new output, to go in the ``cell.outputs`` list of a code cell. """ output = NotebookNode() - if output_type is not None: - output.output_type = unicode_type(output_type) + output.output_type = unicode_type(output_type) if metadata is None: metadata = {} diff --git a/IPython/nbformat/v3/tests/test_nbbase.py b/IPython/nbformat/v3/tests/test_nbbase.py index 2d137b8..351fe5d 100644 --- a/IPython/nbformat/v3/tests/test_nbbase.py +++ b/IPython/nbformat/v3/tests/test_nbbase.py @@ -143,15 +143,15 @@ class TestMetadata(TestCase): class TestOutputs(TestCase): def test_binary_png(self): - out = new_output(output_png=b'\x89PNG\r\n\x1a\n') + out = new_output(output_png=b'\x89PNG\r\n\x1a\n', output_type='display_data') def test_b64b6tes_png(self): - out = new_output(output_png=b'iVBORw0KG') + out = new_output(output_png=b'iVBORw0KG', output_type='display_data') def test_binary_jpeg(self): - out = new_output(output_jpeg=b'\xff\xd8') + out = new_output(output_jpeg=b'\xff\xd8', output_type='display_data') def test_b64b6tes_jpeg(self): - out = new_output(output_jpeg=b'/9') + out = new_output(output_jpeg=b'/9', output_type='display_data')