From ed6e5196603650a27104587548049b61b17fab59 Mon Sep 17 00:00:00 2001 From: Andrea Zonca Date: Thu, 18 Feb 2016 15:06:09 -0800 Subject: [PATCH 1/2] example for SKIPCI --- examples/test_skipci.ipynb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 examples/test_skipci.ipynb diff --git a/examples/test_skipci.ipynb b/examples/test_skipci.ipynb new file mode 100644 index 0000000..08fdbde --- /dev/null +++ b/examples/test_skipci.ipynb @@ -0,0 +1,26 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\"\"\"failing test unless we are on travis SKIPCI\"\"\"\n", + "1/0\n", + "a = 3" + ], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} From 282231f2d48c7d7c250b50af138f524ae2cdd41d Mon Sep 17 00:00:00 2001 From: Andrea Zonca Date: Thu, 18 Feb 2016 15:09:20 -0800 Subject: [PATCH 2/2] reset instead of restart kernel for speed --- pytest_ipynb/plugin.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pytest_ipynb/plugin.py b/pytest_ipynb/plugin.py index 6d1242e..3baf827 100644 --- a/pytest_ipynb/plugin.py +++ b/pytest_ipynb/plugin.py @@ -97,8 +97,8 @@ def __init__(self, name, parent, cell_num, cell): self.cell_description = get_cell_description(self.cell.input) def runtest(self): - self.parent.runner.km.restart_kernel() - + # Instead of a full kernel restart, doing a reset below + #self.parent.runner.km.restart_kernel() if self.parent.notebook_folder: self.parent.runner.kc.execute( """import os @@ -107,6 +107,11 @@ def runtest(self): if ("SKIPCI" in self.cell_description) and ("CI" in os.environ): pass else: + # Using the %reset IPython magic, -f doesn't ask for confirmation + self.parent.runner.kc.execute(""" +from IPython import get_ipython +get_ipython().magic("reset -f") +""") if self.parent.fixture_cell: self.parent.runner.kc.execute(self.parent.fixture_cell.input, allow_stdin=False) msg_id = self.parent.runner.kc.execute(self.cell.input, allow_stdin=False)