Show More
@@ -0,0 +1,56 b'' | |||||
|
1 | """ | |||
|
2 | Module with tests for the extractoutput 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 .base import TransformerTestsBase | |||
|
18 | from ..extractoutput import ExtractOutputTransformer | |||
|
19 | ||||
|
20 | ||||
|
21 | #----------------------------------------------------------------------------- | |||
|
22 | # Class | |||
|
23 | #----------------------------------------------------------------------------- | |||
|
24 | ||||
|
25 | class TestExtractOutput(TransformerTestsBase): | |||
|
26 | """Contains test functions for extractoutput.py""" | |||
|
27 | ||||
|
28 | def test_constructor(self): | |||
|
29 | """Can a ExtractOutputTransformer be constructed?""" | |||
|
30 | transformer = ExtractOutputTransformer() | |||
|
31 | transformer.enabled = True | |||
|
32 | return transformer | |||
|
33 | ||||
|
34 | ||||
|
35 | def test_output(self): | |||
|
36 | """Test the output of the ExtractOutputTransformer""" | |||
|
37 | nb, res = self.test_constructor()(self.build_notebook(), {}) | |||
|
38 | ||||
|
39 | # Check if text was extracted. | |||
|
40 | assert 'text_filename' in nb.worksheets[0].cells[0].outputs[1] | |||
|
41 | text_filename = nb.worksheets[0].cells[0].outputs[1]['text_filename'] | |||
|
42 | ||||
|
43 | # Check if png was extracted. | |||
|
44 | assert 'png_filename' in nb.worksheets[0].cells[0].outputs[6] | |||
|
45 | png_filename = nb.worksheets[0].cells[0].outputs[6]['png_filename'] | |||
|
46 | ||||
|
47 | # Make sure an entry to the resources was added. | |||
|
48 | assert 'outputs' in res | |||
|
49 | ||||
|
50 | # Verify text output | |||
|
51 | assert text_filename in res['outputs'] | |||
|
52 | self.assertEqual(res['outputs'][text_filename], 'b') | |||
|
53 | ||||
|
54 | # Verify png output | |||
|
55 | assert png_filename in res['outputs'] | |||
|
56 | self.assertEqual(res['outputs'][png_filename], 'g') |
General Comments 0
You need to be logged in to leave comments.
Login now