##// END OF EJS Templates
Extracted output are now test against byte arrays instead of strings
Jonathan Frederic -
Show More
@@ -1,62 +1,62 b''
1 1 """
2 2 Module with tests for the extractoutput transformer
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17 from .base import TransformerTestsBase
18 18 from ..extractoutput import ExtractOutputTransformer
19 19
20 20
21 21 #-----------------------------------------------------------------------------
22 22 # Class
23 23 #-----------------------------------------------------------------------------
24 24
25 25 class TestExtractOutput(TransformerTestsBase):
26 26 """Contains test functions for extractoutput.py"""
27 27
28 28
29 29 def build_transformer(self):
30 30 """Make an instance of a transformer"""
31 31 transformer = ExtractOutputTransformer()
32 32 transformer.enabled = True
33 33 return transformer
34 34
35 35
36 36 def test_constructor(self):
37 37 """Can a ExtractOutputTransformer be constructed?"""
38 38 self.build_transformer()
39 39
40 40
41 41 def test_output(self):
42 42 """Test the output of the ExtractOutputTransformer"""
43 43 nb, res = self.build_transformer()(self.build_notebook(), self.build_resources())
44 44
45 45 # Check if text was extracted.
46 46 assert 'text_filename' in nb.worksheets[0].cells[0].outputs[1]
47 47 text_filename = nb.worksheets[0].cells[0].outputs[1]['text_filename']
48 48
49 49 # Check if png was extracted.
50 50 assert 'png_filename' in nb.worksheets[0].cells[0].outputs[6]
51 51 png_filename = nb.worksheets[0].cells[0].outputs[6]['png_filename']
52 52
53 53 # Make sure an entry to the resources was added.
54 54 assert 'outputs' in res
55 55
56 56 # Verify text output
57 57 assert text_filename in res['outputs']
58 self.assertEqual(res['outputs'][text_filename], 'b')
58 self.assertEqual(res['outputs'][text_filename], b'b')
59 59
60 60 # Verify png output
61 61 assert png_filename in res['outputs']
62 self.assertEqual(res['outputs'][png_filename], 'g')
62 self.assertEqual(res['outputs'][png_filename], b'g')
General Comments 0
You need to be logged in to leave comments. Login now