##// END OF EJS Templates
Further refinement
Jonathan Frederic -
Show More
@@ -136,8 +136,20 b' class TestsBase(ParametricTestCase):'
136 136 return path
137 137
138 138
139 def call(self, parameters, raise_on_error=True):
139 def call(self, parameters, ignore_return_code=False):
140 """
141 Execute a, IPython shell command, listening for both Errors and non-zero
142 return codes.
143
144 PARAMETERS:
145 -----------
146 parameters : str
147 List of parameters to pass to IPython.
148 ignore_return_code : optional bool (default False)
149 Throw an OSError if the return code
150 """
151
140 152 stdout, stderr, retcode = get_output_error_code(ipy_cmd + parameters)
141 if retcode != 0 and raise_on_error:
153 if retcode != 0 and not ignore_return_code:
142 154 raise OSError(stderr)
143 155 return stdout, stderr
@@ -39,7 +39,7 b' class TestNbConvertApp(TestsBase):'
39 39 Will help show if no notebooks are specified?
40 40 """
41 41 with self.create_temp_cwd():
42 out, err = self.call('nbconvert --log-level=0', raise_on_error=False)
42 out, err = self.call('nbconvert --log-level 0', ignore_return_code=True)
43 43 assert "see '--help-all'" in out
44 44
45 45
@@ -48,7 +48,7 b' class TestNbConvertApp(TestsBase):'
48 48 Do search patterns work for notebook names?
49 49 """
50 50 with self.create_temp_cwd(['notebook*.ipynb']):
51 self.call("""nbconvert --to="python" --notebooks="['*.ipynb']" --log-level=0""")
51 self.call('nbconvert --to python *.ipynb --log-level 0')
52 52 assert os.path.isfile('notebook1.py')
53 53 assert os.path.isfile('notebook2.py')
54 54
@@ -59,8 +59,8 b' class TestNbConvertApp(TestsBase):'
59 59 """
60 60 with self.create_temp_cwd():
61 61 self.copy_files_to(['notebook*.ipynb'], 'subdir/')
62 self.call('nbconvert --to="python" --log-level=0 --notebooks='
63 """"['%s']"' % os.path.join('subdir', '*.ipynb"""))
62 self.call('nbconvert --to python --log-level 0 ' +
63 os.path.join('subdir', '*.ipynb'))
64 64 assert os.path.isfile('notebook1.py')
65 65 assert os.path.isfile('notebook2.py')
66 66
@@ -70,8 +70,7 b' class TestNbConvertApp(TestsBase):'
70 70 Do explicit notebook names work?
71 71 """
72 72 with self.create_temp_cwd(['notebook*.ipynb']):
73 self.call('nbconvert --log-level=0 --to="python" --notebooks='
74 """"['notebook2.ipynb']\"""")
73 self.call('nbconvert --log-level 0 --to python notebook2')
75 74 assert not os.path.isfile('notebook1.py')
76 75 assert os.path.isfile('notebook2.py')
77 76
@@ -84,8 +83,9 b' class TestNbConvertApp(TestsBase):'
84 83 """
85 84 with self.create_temp_cwd(['notebook2.ipynb']):
86 85 os.rename('notebook2.ipynb', 'notebook with spaces.ipynb')
87 o,e = self.call('nbconvert --log-level=0 --to="latex" "notebook with spaces"'
88 ' --post="PDF" --PDFPostProcessor.verbose=True')
86 o,e = self.call('nbconvert --log-level 0 --to latex '
87 '"notebook with spaces" --post PDF '
88 '--PDFPostProcessor.verbose=True')
89 89 assert os.path.isfile('notebook with spaces.tex')
90 90 assert os.path.isdir('notebook with spaces_files')
91 91 assert os.path.isfile('notebook with spaces.pdf')
@@ -97,8 +97,8 b' class TestNbConvertApp(TestsBase):'
97 97 Do post processors work?
98 98 """
99 99 with self.create_temp_cwd(['notebook1.ipynb']):
100 self.call('nbconvert --log-level=0 --to="latex" notebook1'
101 ' --post="PDF" --PDFPostProcessor.verbose=True')
100 self.call('nbconvert --log-level 0 --to latex notebook1 '
101 '--post PDF --PDFPostProcessor.verbose=True')
102 102 assert os.path.isfile('notebook1.tex')
103 103 assert os.path.isfile('notebook1.pdf')
104 104
@@ -109,8 +109,8 b' class TestNbConvertApp(TestsBase):'
109 109 Do export templates work?
110 110 """
111 111 with self.create_temp_cwd(['notebook2.ipynb']):
112 self.call('nbconvert --log-level=0 --to=slides --notebooks='
113 """"['notebook2.ipynb']" --template=reveal""")
112 self.call('nbconvert --log-level 0 --to slides '
113 'notebook2.ipynb --template reveal')
114 114 assert os.path.isfile('notebook2.slides.html')
115 115 with open('notebook2.slides.html') as f:
116 116 assert '/reveal.css' in f.read()
@@ -121,8 +121,8 b' class TestNbConvertApp(TestsBase):'
121 121 Can a search pattern be used along with matching explicit notebook names?
122 122 """
123 123 with self.create_temp_cwd(['notebook*.ipynb']):
124 self.call('nbconvert --log-level=0 --to="python" --notebooks='
125 """"['*.ipynb','notebook1.ipynb','notebook2.ipynb']\"""")
124 self.call('nbconvert --log-level 0 --to python '
125 '*.ipynb notebook1.ipynb notebook2.ipynb')
126 126 assert os.path.isfile('notebook1.py')
127 127 assert os.path.isfile('notebook2.py')
128 128
@@ -132,8 +132,8 b' class TestNbConvertApp(TestsBase):'
132 132 Can explicit notebook names be used and then a matching search pattern?
133 133 """
134 134 with self.create_temp_cwd(['notebook*.ipynb']):
135 self.call('nbconvert --log-level=0 --to="python" --notebooks='
136 """"['notebook1.ipynb','notebook2.ipynb','*.ipynb']\"""")
135 self.call('nbconvert --log-level 0 --to=python '
136 'notebook1.ipynb notebook2.ipynb *.ipynb')
137 137 assert os.path.isfile('notebook1.py')
138 138 assert os.path.isfile('notebook2.py')
139 139
@@ -143,7 +143,7 b' class TestNbConvertApp(TestsBase):'
143 143 Does the default config work?
144 144 """
145 145 with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py']):
146 self.call('nbconvert --log-level=0')
146 self.call('nbconvert --log-level 0')
147 147 assert os.path.isfile('notebook1.py')
148 148 assert not os.path.isfile('notebook2.py')
149 149
@@ -155,6 +155,6 b' class TestNbConvertApp(TestsBase):'
155 155 with self.create_temp_cwd(['notebook*.ipynb',
156 156 'ipython_nbconvert_config.py',
157 157 'override.py']):
158 self.call('nbconvert --log-level=0 --config="override.py"')
158 self.call('nbconvert --log-level 0 --config="override.py"')
159 159 assert not os.path.isfile('notebook1.py')
160 160 assert os.path.isfile('notebook2.py')
General Comments 0
You need to be logged in to leave comments. Login now