diff --git a/IPython/nbconvert/preprocessors/tests/expected/Clear Output.ipynb b/IPython/nbconvert/preprocessors/tests/files/Clear Output.ipynb similarity index 100% rename from IPython/nbconvert/preprocessors/tests/expected/Clear Output.ipynb rename to IPython/nbconvert/preprocessors/tests/files/Clear Output.ipynb diff --git a/IPython/nbconvert/preprocessors/tests/expected/Factorials.ipynb b/IPython/nbconvert/preprocessors/tests/files/Factorials.ipynb similarity index 100% rename from IPython/nbconvert/preprocessors/tests/expected/Factorials.ipynb rename to IPython/nbconvert/preprocessors/tests/files/Factorials.ipynb diff --git a/IPython/nbconvert/preprocessors/tests/expected/HelloWorld.ipynb b/IPython/nbconvert/preprocessors/tests/files/HelloWorld.ipynb similarity index 100% rename from IPython/nbconvert/preprocessors/tests/expected/HelloWorld.ipynb rename to IPython/nbconvert/preprocessors/tests/files/HelloWorld.ipynb diff --git a/IPython/nbconvert/preprocessors/tests/expected/Inline Image.ipynb b/IPython/nbconvert/preprocessors/tests/files/Inline Image.ipynb similarity index 100% rename from IPython/nbconvert/preprocessors/tests/expected/Inline Image.ipynb rename to IPython/nbconvert/preprocessors/tests/files/Inline Image.ipynb diff --git a/IPython/nbconvert/preprocessors/tests/expected/SVG.ipynb b/IPython/nbconvert/preprocessors/tests/files/SVG.ipynb similarity index 100% rename from IPython/nbconvert/preprocessors/tests/expected/SVG.ipynb rename to IPython/nbconvert/preprocessors/tests/files/SVG.ipynb diff --git a/IPython/nbconvert/preprocessors/tests/expected/Skip Exceptions.ipynb b/IPython/nbconvert/preprocessors/tests/files/Skip Exceptions.ipynb similarity index 100% rename from IPython/nbconvert/preprocessors/tests/expected/Skip Exceptions.ipynb rename to IPython/nbconvert/preprocessors/tests/files/Skip Exceptions.ipynb diff --git a/IPython/nbconvert/preprocessors/tests/expected/Unicode.ipynb b/IPython/nbconvert/preprocessors/tests/files/Unicode.ipynb similarity index 100% rename from IPython/nbconvert/preprocessors/tests/expected/Unicode.ipynb rename to IPython/nbconvert/preprocessors/tests/files/Unicode.ipynb diff --git a/IPython/nbconvert/preprocessors/tests/input/python.png b/IPython/nbconvert/preprocessors/tests/files/python.png similarity index 100% rename from IPython/nbconvert/preprocessors/tests/input/python.png rename to IPython/nbconvert/preprocessors/tests/files/python.png Binary files a/IPython/nbconvert/preprocessors/tests/input/python.png and b/IPython/nbconvert/preprocessors/tests/files/python.png differ diff --git a/IPython/nbconvert/preprocessors/tests/input/Clear Output.ipynb b/IPython/nbconvert/preprocessors/tests/input/Clear Output.ipynb deleted file mode 100644 index e4c155d..0000000 --- a/IPython/nbconvert/preprocessors/tests/input/Clear Output.ipynb +++ /dev/null @@ -1,36 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from IPython.display import clear_output" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "for i in range(10):\n", - " clear_output()\n", - " print(i)" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/IPython/nbconvert/preprocessors/tests/input/Factorials.ipynb b/IPython/nbconvert/preprocessors/tests/input/Factorials.ipynb deleted file mode 100644 index 536e5f4..0000000 --- a/IPython/nbconvert/preprocessors/tests/input/Factorials.ipynb +++ /dev/null @@ -1,36 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "code", - "collapsed": false, - "input": [ - "i, j = 1, 1" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "for m in range(10):\n", - " i, j = j, i + j\n", - " print(j)" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/IPython/nbconvert/preprocessors/tests/input/HelloWorld.ipynb b/IPython/nbconvert/preprocessors/tests/input/HelloWorld.ipynb deleted file mode 100644 index 304924a..0000000 --- a/IPython/nbconvert/preprocessors/tests/input/HelloWorld.ipynb +++ /dev/null @@ -1,24 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "code", - "collapsed": false, - "input": [ - "print(\"Hello World\")" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/IPython/nbconvert/preprocessors/tests/input/Inline Image.ipynb b/IPython/nbconvert/preprocessors/tests/input/Inline Image.ipynb deleted file mode 100644 index 68b6884..0000000 --- a/IPython/nbconvert/preprocessors/tests/input/Inline Image.ipynb +++ /dev/null @@ -1,34 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from IPython.display import Image" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "Image('../input/python.png');" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/IPython/nbconvert/preprocessors/tests/input/SVG.ipynb b/IPython/nbconvert/preprocessors/tests/input/SVG.ipynb deleted file mode 100644 index 35ea9c8..0000000 --- a/IPython/nbconvert/preprocessors/tests/input/SVG.ipynb +++ /dev/null @@ -1,37 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from IPython.display import SVG" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "SVG(data='''\n", - "\n", - " \n", - "''')" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/IPython/nbconvert/preprocessors/tests/input/Skip Exceptions.ipynb b/IPython/nbconvert/preprocessors/tests/input/Skip Exceptions.ipynb deleted file mode 100644 index 278ee91..0000000 --- a/IPython/nbconvert/preprocessors/tests/input/Skip Exceptions.ipynb +++ /dev/null @@ -1,55 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "code", - "collapsed": false, - "input": [ - "raise Exception(\"message\")" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "ename": "Exception", - "evalue": "message", - "output_type": "pyerr", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mException\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"message\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[1;31mException\u001b[0m: message" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "print('ok')" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "ok\n" - ] - } - ], - "prompt_number": 2 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/IPython/nbconvert/preprocessors/tests/input/Unicode.ipynb b/IPython/nbconvert/preprocessors/tests/input/Unicode.ipynb deleted file mode 100644 index b9ede92..0000000 --- a/IPython/nbconvert/preprocessors/tests/input/Unicode.ipynb +++ /dev/null @@ -1,24 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "code", - "collapsed": false, - "input": [ - "print('\u2603')" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/IPython/nbconvert/preprocessors/tests/test_execute.py b/IPython/nbconvert/preprocessors/tests/test_execute.py index d26ebde..4de78f9 100644 --- a/IPython/nbconvert/preprocessors/tests/test_execute.py +++ b/IPython/nbconvert/preprocessors/tests/test_execute.py @@ -6,6 +6,7 @@ Module with tests for the execute preprocessor. # Distributed under the terms of the Modified BSD License. import copy +import glob import os import re @@ -16,7 +17,6 @@ from ..execute import ExecutePreprocessor from IPython.nbconvert.filters import strip_ansi - addr_pat = re.compile(r'0x[0-9a-f]{7,9}') class TestExecute(PreprocessorTestsBase): @@ -71,16 +71,12 @@ class TestExecute(PreprocessorTestsBase): def test_run_notebooks(self): """Runs a series of test notebooks and compares them to their actual output""" current_dir = os.path.dirname(__file__) - input_files = os.listdir(os.path.join(current_dir, 'input')) + input_files = glob.glob(os.path.join(current_dir, 'files', '*.ipynb')) for filename in input_files: - if not filename.endswith(".ipynb"): - continue - with open(os.path.join(current_dir, 'input', filename)) as f: + with open(os.path.join(current_dir, 'files', filename)) as f: input_nb = nbformat.read(f, 'ipynb') - with open(os.path.join(current_dir, 'expected', filename)) as f: - expected_nb = nbformat.read(f, 'ipynb') res = self.build_resources() preprocessor = self.build_preprocessor() - output_nb, _ = preprocessor(input_nb, res) - self.assert_notebooks_equal(output_nb, expected_nb) + output_nb, _ = preprocessor(copy.deepcopy(input_nb), res) + self.assert_notebooks_equal(output_nb, input_nb) diff --git a/setupbase.py b/setupbase.py index 85ef2f6..7c5fe05 100644 --- a/setupbase.py +++ b/setupbase.py @@ -188,8 +188,7 @@ def find_package_data(): [ 'tests/files/*.*', 'exporters/tests/files/*.*', - 'preprocessors/tests/input/*.*', - 'preprocessors/tests/expected/*.*', + 'preprocessors/tests/files/*.*', ], 'IPython.nbconvert.filters' : ['marked.js'], 'IPython.nbformat' : ['tests/*.ipynb','v3/v3.withref.json']