From 17a88b56ce7060960eacffdced12c2e3cbfa459b 2015-02-26 20:30:58 From: Jessica B. Hamrick Date: 2015-02-26 20:30:58 Subject: [PATCH] Add test for when stdin is disabled --- diff --git a/IPython/nbconvert/preprocessors/tests/files/Disable Stdin.ipynb b/IPython/nbconvert/preprocessors/tests/files/Disable Stdin.ipynb new file mode 100644 index 0000000..6f65750 --- /dev/null +++ b/IPython/nbconvert/preprocessors/tests/files/Disable Stdin.ipynb @@ -0,0 +1,36 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "name = input(\"name: \")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.2" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/IPython/nbconvert/preprocessors/tests/test_execute.py b/IPython/nbconvert/preprocessors/tests/test_execute.py index 2cf426f..19b1a0e 100644 --- a/IPython/nbconvert/preprocessors/tests/test_execute.py +++ b/IPython/nbconvert/preprocessors/tests/test_execute.py @@ -89,4 +89,18 @@ class TestExecute(PreprocessorTestsBase): del cell['execution_count'] cell['outputs'] = [] output_nb, _ = preprocessor(cleaned_input_nb, res) - self.assert_notebooks_equal(output_nb, input_nb) + + if os.path.basename(filename) == "Disable Stdin.ipynb": + # We need to special-case this particular notebook, because the + # traceback contains machine-specific stuff like where IPython + # is installed. It is sufficient here to just check that an error + # was thrown, and that it was a StdinNotImplementedError + self.assertEqual(len(output_nb['cells']), 1) + self.assertEqual(len(output_nb['cells'][0]['outputs']), 1) + output = output_nb['cells'][0]['outputs'][0] + self.assertEqual(output['output_type'], 'error') + self.assertEqual(output['ename'], 'StdinNotImplementedError') + self.assertEqual(output['evalue'], 'raw_input was called, but this frontend does not support input requests.') + + else: + self.assert_notebooks_equal(output_nb, input_nb)