Skip to content

Commit d8c9642

Browse files
Oliver LaslettOliver Laslett
Oliver Laslett
authored and
Oliver Laslett
committed
Added installation instructions and cleaned up the main file.
1 parent d1f6a08 commit d8c9642

File tree

2 files changed

+29
-45
lines changed

2 files changed

+29
-45
lines changed

INSTALL

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Install from project directory with:
2+
pip install .
3+
4+
NOTE: This may require root access.

stollen/plugin.py

+25-45
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,6 @@
33
44
Authors: D. Cortes, O. Laslett
55
6-
For now, install pytest-ipynb plugin (
7-
https://github.com/zonca/pytest-ipynb ) :
8-
9-
sudo pip install pytest-ipynb
10-
11-
And replace the file with:
12-
13-
sudo cp pytest_plugin.py /usr/local/lib/python2.7/dist-packages/pytest_ipynb/plugin.py
14-
156
"""
167

178
import pytest
@@ -162,6 +153,7 @@ def teardown(self):
162153
self.kernel.stop()
163154

164155

156+
165157
class IPyNbCell(pytest.Item):
166158
def __init__(self, name, parent, cell_num, cell):
167159
super(IPyNbCell, self).__init__(name, parent)
@@ -172,13 +164,31 @@ def __init__(self, name, parent, cell_num, cell):
172164
#
173165
self.comparisons = None
174166

167+
168+
""" *****************************************************
169+
***************** TESTING FUNCTIONS ***************
170+
***************************************************** """
171+
172+
def repr_failure(self, excinfo):
173+
""" called when self.runtest() raises an exception. """
174+
if isinstance(excinfo.value, NbCellError):
175+
return "\n".join([
176+
"Notebook execution failed",
177+
"Cell %d: %s\n\n"
178+
"Input:\n%s\n\n"
179+
"Traceback:\n%s\n" % excinfo.value.args,
180+
])
181+
else:
182+
return "pytest plugin exception: %s" % str(excinfo.value)
183+
184+
def reportinfo(self):
185+
description = "cell %d" % self.cell_num
186+
return self.fspath, 0, description
187+
175188
def compare_outputs(self, test, ref, skip_compare=('png',
176189
'traceback',
177190
'latex',
178191
'prompt_number')):
179-
"""
180-
181-
"""
182192
self.comparisons = []
183193

184194
for key in ref:
@@ -215,26 +225,10 @@ def compare_outputs(self, test, ref, skip_compare=('png',
215225
return False
216226
return True
217227

228+
""" *****************************************************
229+
***************************************************** """
218230

219231

220-
""" TESTING FUNCTIONS """
221-
222-
def repr_failure(self, excinfo):
223-
""" called when self.runtest() raises an exception. """
224-
if isinstance(excinfo.value, NbCellError):
225-
return "\n".join([
226-
"Notebook execution failed",
227-
"Cell %d: %s\n\n"
228-
"Input:\n%s\n\n"
229-
"Traceback:\n%s\n" % excinfo.value.args,
230-
])
231-
else:
232-
return "pytest plugin exception: %s" % str(excinfo.value)
233-
234-
def reportinfo(self):
235-
description = "cell %d" % self.cell_num
236-
return self.fspath, 0, description
237-
238232
def runtest(self):
239233
"""
240234
Run all the cell tests in one kernel without restarting.
@@ -282,19 +276,13 @@ def runtest(self):
282276
# print msg['content']
283277
# print msg['msg_type']
284278

285-
# Breaks on the last message
286-
# This is useful when no piece of code is left to be executed
287-
# in acell. It doesnt work well for us
288-
# if (msg.get("parent_header", None) and
289-
# msg["parent_header"].get("msg_id", None) == msg_id):
290-
# break
291279
except Empty:
292280
# This is not working: ! The code will not be checked
293281
# if the time is out (when the cell stops to be executed?)
294282
# raise NbCellError("Timeout of %d seconds exceeded"
295283
# " executing cell: %s" (timeout,
296284
# self.cell.input))
297-
# This is better: Just break the loop when the output is empty
285+
# Just break the loop when the output is empty
298286
break
299287

300288
"""
@@ -398,14 +386,6 @@ def runtest(self):
398386
if not self.compare_outputs(out, ref):
399387
failed = True
400388

401-
# if failed:
402-
# failures += 1
403-
# else:
404-
# successes += 1
405-
# sys.stdout.write('.')
406-
407-
# raise NotImplementedError
408-
409389
# if reply['status'] == 'error':
410390
# Traceback is only when an error is raised (?)
411391

0 commit comments

Comments
 (0)