From 729413e85e8825f1ea355bfc78474574006a0481 2014-11-01 23:40:59 From: MinRK Date: 2014-11-01 23:40:59 Subject: [PATCH] mv stream.stream > stream.name in nbformat.v4 matches message spec --- diff --git a/IPython/nbformat/v4/nbbase.py b/IPython/nbformat/v4/nbbase.py index a1cea76..473bd62 100644 --- a/IPython/nbformat/v4/nbbase.py +++ b/IPython/nbformat/v4/nbbase.py @@ -44,7 +44,7 @@ def new_output(output_type, mime_bundle=None, **kwargs): # populate defaults: output.setdefault('metadata', NotebookNode()) if output_type == 'stream': - output.setdefault('stream', 'stdout') + output.setdefault('name', 'stdout') output.setdefault('text', '') validate(output, output_type) return output diff --git a/IPython/nbformat/v4/nbformat.v4.schema.json b/IPython/nbformat/v4/nbformat.v4.schema.json index 2049ed6..e34b0a7 100644 --- a/IPython/nbformat/v4/nbformat.v4.schema.json +++ b/IPython/nbformat/v4/nbformat.v4.schema.json @@ -250,15 +250,15 @@ "description": "Stream output from a code cell.", "type": "object", "additionalProperties": false, - "required": ["output_type", "metadata", "stream", "text"], + "required": ["output_type", "metadata", "name", "text"], "properties": { "output_type": { "description": "Type of cell output.", "enum": ["stream"] }, "metadata": {"$ref": "#/definitions/misc/output_metadata"}, - "stream": { - "description": "The stream type/destination.", + "name": { + "description": "The name of the stream (stdout, stderr).", "type": "string" }, "text": { diff --git a/IPython/nbformat/v4/tests/nbexamples.py b/IPython/nbformat/v4/tests/nbexamples.py index 5a01174..26f833a 100644 --- a/IPython/nbformat/v4/tests/nbexamples.py +++ b/IPython/nbformat/v4/tests/nbexamples.py @@ -91,7 +91,7 @@ cells.append(new_code_cell( text='foo\rbar\r\n' ),new_output( output_type=u'stream', - stream='stderr', + name='stderr', text='\rfoo\rbar\n' )] )) diff --git a/IPython/nbformat/v4/tests/test_nbbase.py b/IPython/nbformat/v4/tests/test_nbbase.py index 43170f0..1e23241 100644 --- a/IPython/nbformat/v4/tests/test_nbbase.py +++ b/IPython/nbformat/v4/tests/test_nbbase.py @@ -55,8 +55,10 @@ def test_empty_display_data(): nt.assert_equal(output.output_type, 'display_data') def test_empty_stream(): - output = new_output('stream', stream='stdout', text='') + output = new_output('stream') nt.assert_equal(output.output_type, 'stream') + nt.assert_equal(output.name, 'stdout') + nt.assert_equal(output.text, '') def test_empty_execute_result(): output = new_output('execute_result', prompt_number=1) @@ -103,3 +105,8 @@ def test_code_cell_with_outputs(): er = cell.outputs[-1] nt.assert_equal(er.prompt_number, 10) nt.assert_equal(er['output_type'], 'execute_result') + +def test_stream(): + output = new_output('stream', name='stderr', text='hello there') + nt.assert_equal(output.name, 'stderr') + nt.assert_equal(output.text, 'hello there')