From fb70cee2742dd0033a94d5136c148581a64eb58b 2014-03-19 19:42:49 From: Jonathan Frederic Date: 2014-03-19 19:42:49 Subject: [PATCH] Added test --- diff --git a/IPython/nbconvert/preprocessors/tests/test_coalescestreams.py b/IPython/nbconvert/preprocessors/tests/test_coalescestreams.py index fd9c14f..8d96794 100644 --- a/IPython/nbconvert/preprocessors/tests/test_coalescestreams.py +++ b/IPython/nbconvert/preprocessors/tests/test_coalescestreams.py @@ -13,7 +13,6 @@ Module with tests for the coalescestreams preprocessor #----------------------------------------------------------------------------- # Imports #----------------------------------------------------------------------------- - from IPython.nbformat import current as nbformat from .base import PreprocessorTestsBase @@ -23,7 +22,6 @@ from ..coalescestreams import coalesce_streams #----------------------------------------------------------------------------- # Class #----------------------------------------------------------------------------- - class TestCoalesceStreams(PreprocessorTestsBase): """Contains test functions for coalescestreams.py""" @@ -38,10 +36,8 @@ class TestCoalesceStreams(PreprocessorTestsBase): self.assertEqual(outputs[2].text, "cd") self.assertEqual(outputs[3].text, "ef") - def test_coalesce_sequenced_streams(self): """Can the coalesce streams preprocessor merge a sequence of streams?""" - outputs = [nbformat.new_output(output_type="stream", stream="stdout", output_text="0"), nbformat.new_output(output_type="stream", stream="stdout", output_text="1"), nbformat.new_output(output_type="stream", stream="stdout", output_text="2"), @@ -58,3 +54,19 @@ class TestCoalesceStreams(PreprocessorTestsBase): nb, res = coalesce_streams(nb, res) outputs = nb.worksheets[0].cells[0].outputs self.assertEqual(outputs[0].text, u'01234567') + + def test_coalesce_replace_streams(self): + """Are \\r characters handled?""" + outputs = [nbformat.new_output(output_type="stream", stream="stdout", output_text="z"), + nbformat.new_output(output_type="stream", stream="stdout", output_text="\ra"), + nbformat.new_output(output_type="stream", stream="stdout", output_text="\nz\rb"), + nbformat.new_output(output_type="stream", stream="stdout", output_text="\nz"), + nbformat.new_output(output_type="stream", stream="stdout", output_text="\rc")] + cells=[nbformat.new_code_cell(input="# None", prompt_number=1,outputs=outputs)] + worksheets = [nbformat.new_worksheet(name="worksheet1", cells=cells)] + + nb = nbformat.new_notebook(name="notebook1", worksheets=worksheets) + res = self.build_resources() + nb, res = coalesce_streams(nb, res) + outputs = nb.worksheets[0].cells[0].outputs + self.assertEqual(outputs[0].text, u'a\nb\nc')