##// END OF EJS Templates
Merge pull request #8301 from minrk/rm-qtconsole...
Merge pull request #8301 from minrk/rm-qtconsole remove qtconsole

File last commit:

r20906:1a805ad1
r21231:79730a28 merge
Show More
test_coalescestreams.py
58 lines | 2.9 KiB | text/x-python | PythonLexer
MinRK
fix some validation bugs in v3...
r18244 """Tests for the coalescestreams preprocessor"""
Jonathan Frederic
Add coalesce streams test
r12021
MinRK
fix some validation bugs in v3...
r18244 # Copyright (c) IPython Development Team.
Jonathan Frederic
Add coalesce streams test
r12021 # Distributed under the terms of the Modified BSD License.
MinRK
Don't use nbformat.current in nbconvert
r18605 from IPython.nbformat import v4 as nbformat
Jonathan Frederic
Added test
r12296
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 from .base import PreprocessorTestsBase
Jonathan Frederic
Add coalesce streams test
r12021 from ..coalescestreams import coalesce_streams
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 class TestCoalesceStreams(PreprocessorTestsBase):
Jonathan Frederic
Add coalesce streams test
r12021 """Contains test functions for coalescestreams.py"""
def test_coalesce_streams(self):
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 """coalesce_streams preprocessor output test"""
Jonathan Frederic
Expanded transformer pass line, for easier debugging
r12039 nb = self.build_notebook()
res = self.build_resources()
nb, res = coalesce_streams(nb, res)
MinRK
update nbconvert to nbformat 4
r18580 outputs = nb.cells[0].outputs
Jonathan Frederic
Fixes small things pointed out by @minrk
r12035 self.assertEqual(outputs[0].text, "a")
MinRK
update nbconvert to nbformat 4
r18580 self.assertEqual(outputs[1].output_type, "display_data")
Jonathan Frederic
Fixes small things pointed out by @minrk
r12035 self.assertEqual(outputs[2].text, "cd")
self.assertEqual(outputs[3].text, "ef")
Jonathan Frederic
Added test
r12296
def test_coalesce_sequenced_streams(self):
"""Can the coalesce streams preprocessor merge a sequence of streams?"""
MinRK
update nbconvert to nbformat 4
r18580 outputs = [nbformat.new_output(output_type="stream", name="stdout", text="0"),
nbformat.new_output(output_type="stream", name="stdout", text="1"),
nbformat.new_output(output_type="stream", name="stdout", text="2"),
nbformat.new_output(output_type="stream", name="stdout", text="3"),
nbformat.new_output(output_type="stream", name="stdout", text="4"),
nbformat.new_output(output_type="stream", name="stdout", text="5"),
nbformat.new_output(output_type="stream", name="stdout", text="6"),
nbformat.new_output(output_type="stream", name="stdout", text="7")]
MinRK
s/prompt_number/execution_count in nbformat 4
r18587 cells=[nbformat.new_code_cell(source="# None", execution_count=1,outputs=outputs)]
MinRK
update nbconvert to nbformat 4
r18580
nb = nbformat.new_notebook(cells=cells)
Jonathan Frederic
Added test
r12296 res = self.build_resources()
nb, res = coalesce_streams(nb, res)
MinRK
update nbconvert to nbformat 4
r18580 outputs = nb.cells[0].outputs
Jonathan Frederic
Added test
r12296 self.assertEqual(outputs[0].text, u'01234567')
Jonathan Frederic
Added test
r15867
def test_coalesce_replace_streams(self):
"""Are \\r characters handled?"""
MinRK
update nbconvert to nbformat 4
r18580 outputs = [nbformat.new_output(output_type="stream", name="stdout", text="z"),
nbformat.new_output(output_type="stream", name="stdout", text="\ra"),
nbformat.new_output(output_type="stream", name="stdout", text="\nz\rb"),
nbformat.new_output(output_type="stream", name="stdout", text="\nz"),
nbformat.new_output(output_type="stream", name="stdout", text="\rc\n"),
nbformat.new_output(output_type="stream", name="stdout", text="z\rz\rd")]
MinRK
s/prompt_number/execution_count in nbformat 4
r18587 cells=[nbformat.new_code_cell(source="# None", execution_count=1,outputs=outputs)]
MinRK
update nbconvert to nbformat 4
r18580
nb = nbformat.new_notebook(cells=cells)
Jonathan Frederic
Added test
r15867 res = self.build_resources()
nb, res = coalesce_streams(nb, res)
MinRK
update nbconvert to nbformat 4
r18580 outputs = nb.cells[0].outputs
Jonathan Frederic
Added one more test, multiple \r on one line
r15870 self.assertEqual(outputs[0].text, u'a\nb\nc\nd')