From 8df1a1233e13a80d3e0ef2dfec8af15394e77b66 2014-06-26 20:21:27 From: Julia Evans Date: 2014-06-26 20:21:27 Subject: [PATCH] Start adding tests from runipy --- diff --git a/IPython/nbconvert/preprocessors/tests/expected/Clear Output.ipynb b/IPython/nbconvert/preprocessors/tests/expected/Clear Output.ipynb new file mode 100644 index 0000000..ef5d5cf --- /dev/null +++ b/IPython/nbconvert/preprocessors/tests/expected/Clear Output.ipynb @@ -0,0 +1,46 @@ +{ + "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": [], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for i in range(10):\n", + " clear_output()\n", + " print i" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "9\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/IPython/nbconvert/preprocessors/tests/expected/Factorials.ipynb b/IPython/nbconvert/preprocessors/tests/expected/Factorials.ipynb new file mode 100644 index 0000000..4db6b65 --- /dev/null +++ b/IPython/nbconvert/preprocessors/tests/expected/Factorials.ipynb @@ -0,0 +1,55 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "collapsed": false, + "input": [ + "i, j = 1, 1" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for m in range(10):\n", + " i, j = j, i + j\n", + " print j" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n", + "3\n", + "5\n", + "8\n", + "13\n", + "21\n", + "34\n", + "55\n", + "89\n", + "144\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/IPython/nbconvert/preprocessors/tests/expected/HelloWorld.ipynb b/IPython/nbconvert/preprocessors/tests/expected/HelloWorld.ipynb new file mode 100644 index 0000000..67ea274 --- /dev/null +++ b/IPython/nbconvert/preprocessors/tests/expected/HelloWorld.ipynb @@ -0,0 +1,33 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Hello World\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Hello World\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/IPython/nbconvert/preprocessors/tests/expected/Inline Image.ipynb b/IPython/nbconvert/preprocessors/tests/expected/Inline Image.ipynb new file mode 100644 index 0000000..c3527e1 --- /dev/null +++ b/IPython/nbconvert/preprocessors/tests/expected/Inline Image.ipynb @@ -0,0 +1,36 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from IPython.display import Image" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "Image('../input/python.png');" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/IPython/nbconvert/preprocessors/tests/expected/SVG.ipynb b/IPython/nbconvert/preprocessors/tests/expected/SVG.ipynb new file mode 100644 index 0000000..4c9e40a --- /dev/null +++ b/IPython/nbconvert/preprocessors/tests/expected/SVG.ipynb @@ -0,0 +1,53 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from IPython.display import SVG" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "SVG(data='''\n", + "\n", + " \n", + "''')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 2, + "svg": [ + "\n", + " \n", + "" + ], + "text": [ + "" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/IPython/nbconvert/preprocessors/tests/expected/Skip Exceptions.ipynb b/IPython/nbconvert/preprocessors/tests/expected/Skip Exceptions.ipynb new file mode 100644 index 0000000..1cae18d --- /dev/null +++ b/IPython/nbconvert/preprocessors/tests/expected/Skip Exceptions.ipynb @@ -0,0 +1,55 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "collapsed": false, + "input": [ + "1 / 0" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "ename": "ZeroDivisionError", + "evalue": "integer division or modulo by zero", + "output_type": "pyerr", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mZeroDivisionError\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;36m1\u001b[0m \u001b[1;33m/\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;31mZeroDivisionError\u001b[0m: integer division or modulo by zero" + ] + } + ], + "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/expected/Unicode.ipynb b/IPython/nbconvert/preprocessors/tests/expected/Unicode.ipynb new file mode 100644 index 0000000..3fd4818 --- /dev/null +++ b/IPython/nbconvert/preprocessors/tests/expected/Unicode.ipynb @@ -0,0 +1,33 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print '\u2603'" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\u2603\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/IPython/nbconvert/preprocessors/tests/input/Clear Output.ipynb b/IPython/nbconvert/preprocessors/tests/input/Clear Output.ipynb new file mode 100644 index 0000000..3920cb2 --- /dev/null +++ b/IPython/nbconvert/preprocessors/tests/input/Clear Output.ipynb @@ -0,0 +1,36 @@ +{ + "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 new file mode 100644 index 0000000..1736948 --- /dev/null +++ b/IPython/nbconvert/preprocessors/tests/input/Factorials.ipynb @@ -0,0 +1,36 @@ +{ + "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 new file mode 100644 index 0000000..2edf785 --- /dev/null +++ b/IPython/nbconvert/preprocessors/tests/input/HelloWorld.ipynb @@ -0,0 +1,24 @@ +{ + "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 new file mode 100644 index 0000000..68b6884 --- /dev/null +++ b/IPython/nbconvert/preprocessors/tests/input/Inline Image.ipynb @@ -0,0 +1,34 @@ +{ + "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 new file mode 100644 index 0000000..35ea9c8 --- /dev/null +++ b/IPython/nbconvert/preprocessors/tests/input/SVG.ipynb @@ -0,0 +1,37 @@ +{ + "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 new file mode 100644 index 0000000..1cae18d --- /dev/null +++ b/IPython/nbconvert/preprocessors/tests/input/Skip Exceptions.ipynb @@ -0,0 +1,55 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "collapsed": false, + "input": [ + "1 / 0" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "ename": "ZeroDivisionError", + "evalue": "integer division or modulo by zero", + "output_type": "pyerr", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mZeroDivisionError\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;36m1\u001b[0m \u001b[1;33m/\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;31mZeroDivisionError\u001b[0m: integer division or modulo by zero" + ] + } + ], + "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 new file mode 100644 index 0000000..178f502 --- /dev/null +++ b/IPython/nbconvert/preprocessors/tests/input/Unicode.ipynb @@ -0,0 +1,24 @@ +{ + "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/input/python.png b/IPython/nbconvert/preprocessors/tests/input/python.png new file mode 100644 index 0000000000000000000000000000000000000000..c56d4c022a7130beed2ee67d7fff7274aff5de1e GIT binary patch literal 8758 zc${6DWl$VV*M3vR&{ceg-rcZbDYf-LTf1zCay5AF^j1PksK+$Bih!R6i5 z_wSpk?ymVU-Di&6=bEaCQTr&5jX{P1006e4f{X@y9fA)vv{&%i$VsRcz94%@DQcm? zuK+ZwX!t#;r>vf*ri+cIkGZ=w;N#=NZtv{iVQKDa&F_A3R%teStY`IKE~Q9w!(_zf#ZRv zf2ffqwWQ-oxTK`APG0?t=1Pk}SBNJukN$tN`Gv2Df|nO>O=YFBz>*WpZYXsXLZbO) zB!k1l`}8+#_rh1f&(Ci_yF%xXu|tJm`19)|=fVW{ZuPPGtP{epen~C^W2?e3MZTqM z!iF(fzNH+i(YVw_PnH35H7@qJ*oysOJrGfm@%q_)qMH6PAUjscRK&BfdO1^Q+rcTQ8 z#%?K5=@a$sR=gS*NOK}plv*ew3kVC_7D!U)SyrTBBY3Ww^&%y~?e<{msh6bSUz;9UZ}TX1tX~0X!(0*WHU>vD3ddwgZ^iJP z5lK#<>BW!?VgOKnX}TGuwC1FII>Z`=il?)uf{Cg8cNw`2R( zjNdyF*~2Vd)=+DH>mnYaTZ%8PkW>Dx$jd0+yv-%XC`+2U(JuDHhtQVp2nVcydxyF$eayu=on%<((rP3j_ip zQJV}@G%MzK5(lNXE_`!GN0o)cdZP{6a@7#(I%AtI zMNA#)RbwFrY;Uf1hEsq1`lY0e!D?&0n}`j+4M!L$Z9~7&}uI?BH;x zD*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@tllDR;EQI@Y$YQ5m0zvWpPQU+7kFA=h#EMU%-M^m!TD`6;hkF}uy}-^2fAOoTt>i>f5;nz zfy5?oC2Jv$-N9bA(j8fTmES(zdh9lRf1nXtd76z(i~XcCj(G@K@tlaIgvlH{p1CA` z=wTM-So(C*i3~s_3;jRX*pQe8|2>5wOCC_m1CYwk$h!3cKYUunV=l_E3>YSBk9r$t= zmG$CqQ}CIrE#=S65N0czDja#A_ewf;kJHDY{)y7z)X_(F9MIU)#A35YMMOYaS24b% zo<<*yx)X`onF#V9H{@D4Z{xOfr&ZfP;Zw1Pk+>lqI48z^1#~u!2>AXxA)RR704^mg zx^{M1CZJ+!=_9m#Wb){xJ&77VAFi$KRy}WUXey!kkqaDWS%?PPrZ_itMdSbgq4VFr z046)$Y0#{6y4bS!CgiBHi6P71W~Y4}OZZu3Pqyl%Cd}AzBR2$~N$Q``Y>z1aZM%zs zUA17rXiL{GtVtJI`{%~8adGP2o0k^;#8u6{+{jN%v`yLkZPld>$IbY1Ncd$Dh}$XY zGEt6Nov||BQa3TA-Ff6w1OU7|ZS^I@#nm%9UdM8ID|f<(CD9dv^l>WNqz6b6m@8p6 zL%z~t$v+S#P5a4)4@fP+T!Oit+!L7094#S-G8|U{=@=%Li)SVg^;`-8jhHe%%JI}V z-zlurW6+1Ltlgzmd`IHHcMT(#%!qJO5`=U?`P(h#(E!jomRrRYwVo65^p2A|fk>E) zWpE-FZ|0*OTeuVu9P#>=HGYFDsn zmyb4J<;G`Fn@>_=C(_DQ@+y^sx>pUE_rg-Zh8pRV0pZtQ#9tSP zuw#_ZaR}VJh1LSf?Yi)i{>Qc@7AmF;Yq9^aBEl8^=e`LzWiKCK+d|IN?hDQ}Q(hJzd4~ literal 0 Hc$@', cell['text']) + return cell + + + def assert_notebooks_equal(self, expected, actual): + expected_cells = expected['worksheets'][0]['cells'] + actual_cells = actual['worksheets'][0]['cells'] + assert len(expected_cells) == len(actual_cells) + + # TODO: what does this code do? + for expected_out, actual_out in zip(expected_cells, actual_cells): + for k in set(expected_out).union(actual_out): + if k == 'outputs': + self.assertEquals(len(expected_out[k]), len(actual_out[k])) + for e, a in zip(expected_out[k], actual_out[k]): + assert self.prepare_cell(e) == self.prepare_cell(a) + def build_preprocessor(self): """Make an instance of a preprocessor""" @@ -30,16 +54,25 @@ class TestExecute(PreprocessorTestsBase): preprocessor.enabled = True return preprocessor + def test_constructor(self): """Can a ExecutePreprocessor be constructed?""" self.build_preprocessor() - def test_correct_output(self): - """Test that ExecutePreprocessor evaluates a cell to the right thing""" - nb = self.build_notebook() - res = self.build_resources() - nb.worksheets[0].cells[0].input = "print 'hi!'" - preprocessor = self.build_preprocessor() - nb, res = preprocessor(nb, res) - expected_outputs = [{'output_type': 'stream', 'stream': 'stdout', 'text': 'hi!\n'}] - assert nb.worksheets[0].cells[0].outputs == expected_outputs + + 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')) + for filename in input_files: + if not filename.endswith(".ipynb"): + continue + with open(os.path.join(current_dir, 'input', 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) +