##// END OF EJS Templates
output_type should not be optional in new_output...
MinRK -
Show More
@@ -58,7 +58,7 class APITest(NotebookTestBase):
58 nb.worksheets = [ws]
58 nb.worksheets = [ws]
59 ws.cells.append(new_heading_cell(u'Created by test ³'))
59 ws.cells.append(new_heading_cell(u'Created by test ³'))
60 cc1 = new_code_cell(input=u'print(2*6)')
60 cc1 = new_code_cell(input=u'print(2*6)')
61 cc1.outputs.append(new_output(output_text=u'12'))
61 cc1.outputs.append(new_output(output_text=u'12', output_type='stream'))
62 cc1.outputs.append(new_output(output_png=png_green_pixel, output_type='pyout'))
62 cc1.outputs.append(new_output(output_png=png_green_pixel, output_type='pyout'))
63 ws.cells.append(cc1)
63 ws.cells.append(cc1)
64
64
@@ -4,22 +4,10 The Python representation of a notebook is a nested structure of
4 dictionary subclasses that support attribute access
4 dictionary subclasses that support attribute access
5 (IPython.utils.ipstruct.Struct). The functions in this module are merely
5 (IPython.utils.ipstruct.Struct). The functions in this module are merely
6 helpers to build the structs in the right form.
6 helpers to build the structs in the right form.
7
8 Authors:
9
10 * Brian Granger
11 """
7 """
12
8
13 #-----------------------------------------------------------------------------
9 # Copyright (c) IPython Development Team.
14 # Copyright (C) 2008-2011 The IPython Development Team
10 # Distributed under the terms of the Modified BSD License.
15 #
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
18 #-----------------------------------------------------------------------------
19
20 #-----------------------------------------------------------------------------
21 # Imports
22 #-----------------------------------------------------------------------------
23
11
24 import pprint
12 import pprint
25 import uuid
13 import uuid
@@ -51,15 +39,14 def from_dict(d):
51 return d
39 return d
52
40
53
41
54 def new_output(output_type=None, output_text=None, output_png=None,
42 def new_output(output_type, output_text=None, output_png=None,
55 output_html=None, output_svg=None, output_latex=None, output_json=None,
43 output_html=None, output_svg=None, output_latex=None, output_json=None,
56 output_javascript=None, output_jpeg=None, prompt_number=None,
44 output_javascript=None, output_jpeg=None, prompt_number=None,
57 ename=None, evalue=None, traceback=None, stream=None, metadata=None):
45 ename=None, evalue=None, traceback=None, stream=None, metadata=None):
58 """Create a new output, to go in the ``cell.outputs`` list of a code cell.
46 """Create a new output, to go in the ``cell.outputs`` list of a code cell.
59 """
47 """
60 output = NotebookNode()
48 output = NotebookNode()
61 if output_type is not None:
49 output.output_type = unicode_type(output_type)
62 output.output_type = unicode_type(output_type)
63
50
64 if metadata is None:
51 if metadata is None:
65 metadata = {}
52 metadata = {}
@@ -143,15 +143,15 class TestMetadata(TestCase):
143
143
144 class TestOutputs(TestCase):
144 class TestOutputs(TestCase):
145 def test_binary_png(self):
145 def test_binary_png(self):
146 out = new_output(output_png=b'\x89PNG\r\n\x1a\n')
146 out = new_output(output_png=b'\x89PNG\r\n\x1a\n', output_type='display_data')
147
147
148 def test_b64b6tes_png(self):
148 def test_b64b6tes_png(self):
149 out = new_output(output_png=b'iVBORw0KG')
149 out = new_output(output_png=b'iVBORw0KG', output_type='display_data')
150
150
151 def test_binary_jpeg(self):
151 def test_binary_jpeg(self):
152 out = new_output(output_jpeg=b'\xff\xd8')
152 out = new_output(output_jpeg=b'\xff\xd8', output_type='display_data')
153
153
154 def test_b64b6tes_jpeg(self):
154 def test_b64b6tes_jpeg(self):
155 out = new_output(output_jpeg=b'/9')
155 out = new_output(output_jpeg=b'/9', output_type='display_data')
156
156
157
157
General Comments 0
You need to be logged in to leave comments. Login now