Skip to content
This repository was archived by the owner on Dec 23, 2018. It is now read-only.

Reset kernel #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions examples/test_skipci.ipynb
Original file line number Diff line number Diff line change
@@ -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": {}
}
]
}
9 changes: 7 additions & 2 deletions pytest_ipynb/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down