Show More
|
1 | NO CONTENT: new file 100644 |
@@ -0,0 +1,48 | |||
|
1 | """ | |
|
2 | Module with tests for the coalescestreams transformer | |
|
3 | """ | |
|
4 | ||
|
5 | #----------------------------------------------------------------------------- | |
|
6 | # Copyright (c) 2013, the IPython Development Team. | |
|
7 | # | |
|
8 | # Distributed under the terms of the Modified BSD License. | |
|
9 | # | |
|
10 | # The full license is in the file COPYING.txt, distributed with this software. | |
|
11 | #----------------------------------------------------------------------------- | |
|
12 | ||
|
13 | #----------------------------------------------------------------------------- | |
|
14 | # Imports | |
|
15 | #----------------------------------------------------------------------------- | |
|
16 | ||
|
17 | from ...tests.base import TestsBase | |
|
18 | from ..coalescestreams import coalesce_streams | |
|
19 | ||
|
20 | from IPython.nbformat import current as nbformat | |
|
21 | ||
|
22 | #----------------------------------------------------------------------------- | |
|
23 | # Class | |
|
24 | #----------------------------------------------------------------------------- | |
|
25 | ||
|
26 | class TestCoalesceStreams(TestsBase): | |
|
27 | """Contains test functions for coalescestreams.py""" | |
|
28 | ||
|
29 | ||
|
30 | def build_test_notebook(self): | |
|
31 | outputs = [nbformat.new_output(output_type="stream", stream="stdout", output_text="a"), | |
|
32 | nbformat.new_output(output_type="text", output_text="b"), | |
|
33 | nbformat.new_output(output_type="stream", stream="stdout", output_text="c"), | |
|
34 | nbformat.new_output(output_type="stream", stream="stdout", output_text="d"), | |
|
35 | nbformat.new_output(output_type="stream", stream="stderr", output_text="e"), | |
|
36 | nbformat.new_output(output_type="stream", stream="stderr", output_text="f")] | |
|
37 | cells=[nbformat.new_code_cell(input="test", | |
|
38 | prompt_number=1,outputs=outputs)] | |
|
39 | worksheets = [nbformat.new_worksheet(name="worksheet1", cells=cells)] | |
|
40 | return nbformat.new_notebook(name="notebook1", worksheets=worksheets) | |
|
41 | ||
|
42 | def test_coalesce_streams(self): | |
|
43 | nb, res = coalesce_streams(self.build_test_notebook(), {}) | |
|
44 | self.assertEqual(nb.worksheets[0].cells[0].outputs[0].text, "a") | |
|
45 | self.assertEqual(nb.worksheets[0].cells[0].outputs[1].output_type, "text") | |
|
46 | self.assertEqual(nb.worksheets[0].cells[0].outputs[2].text, "cd") | |
|
47 | self.assertEqual(nb.worksheets[0].cells[0].outputs[3].text, "ef") | |
|
48 | No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now