##// END OF EJS Templates
s/clearoutput/execute/
Julia Evans -
Show More
@@ -1,45 +1,45 b''
1 """
1 """
2 Module with tests for the clearoutput preprocessor.
2 Module with tests for the execute preprocessor.
3 """
3 """
4
4
5 # Copyright (c) IPython Development Team.
5 # Copyright (c) IPython Development Team.
6 # Distributed under the terms of the Modified BSD License.
6 # Distributed under the terms of the Modified BSD License.
7
7
8 #-----------------------------------------------------------------------------
8 #-----------------------------------------------------------------------------
9 # Imports
9 # Imports
10 #-----------------------------------------------------------------------------
10 #-----------------------------------------------------------------------------
11 import copy
11 import copy
12
12
13 from IPython.nbformat import current as nbformat
13 from IPython.nbformat import current as nbformat
14
14
15 from .base import PreprocessorTestsBase
15 from .base import PreprocessorTestsBase
16 from ..execute import ExecutePreprocessor
16 from ..execute import ExecutePreprocessor
17
17
18
18
19 #-----------------------------------------------------------------------------
19 #-----------------------------------------------------------------------------
20 # Class
20 # Class
21 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
22
22
23 class TestExecute(PreprocessorTestsBase):
23 class TestExecute(PreprocessorTestsBase):
24 """Contains test functions for execute.py"""
24 """Contains test functions for execute.py"""
25
25
26
26
27 def build_preprocessor(self):
27 def build_preprocessor(self):
28 """Make an instance of a preprocessor"""
28 """Make an instance of a preprocessor"""
29 preprocessor = ExecutePreprocessor()
29 preprocessor = ExecutePreprocessor()
30 preprocessor.enabled = True
30 preprocessor.enabled = True
31 return preprocessor
31 return preprocessor
32
32
33 def test_constructor(self):
33 def test_constructor(self):
34 """Can a ExecutePreprocessor be constructed?"""
34 """Can a ExecutePreprocessor be constructed?"""
35 self.build_preprocessor()
35 self.build_preprocessor()
36
36
37 def test_correct_output(self):
37 def test_correct_output(self):
38 """Test that ExecutePreprocessor evaluates a cell to the right thing"""
38 """Test that ExecutePreprocessor evaluates a cell to the right thing"""
39 nb = self.build_notebook()
39 nb = self.build_notebook()
40 res = self.build_resources()
40 res = self.build_resources()
41 nb.worksheets[0].cells[0].input = "print 'hi!'"
41 nb.worksheets[0].cells[0].input = "print 'hi!'"
42 preprocessor = self.build_preprocessor()
42 preprocessor = self.build_preprocessor()
43 nb, res = preprocessor(nb, res)
43 nb, res = preprocessor(nb, res)
44 expected_outputs = [{'output_type': 'stream', 'stream': 'stdout', 'text': 'hi!\n'}]
44 expected_outputs = [{'output_type': 'stream', 'stream': 'stdout', 'text': 'hi!\n'}]
45 assert nb.worksheets[0].cells[0].outputs == expected_outputs
45 assert nb.worksheets[0].cells[0].outputs == expected_outputs
General Comments 0
You need to be logged in to leave comments. Login now