diff --git a/IPython/nbconvert/tests/base.py b/IPython/nbconvert/tests/base.py index 4edfff7..374ff0f 100644 --- a/IPython/nbconvert/tests/base.py +++ b/IPython/nbconvert/tests/base.py @@ -20,6 +20,13 @@ import shutil import IPython from IPython.utils.tempdir import TemporaryDirectory from IPython.utils.process import get_output_error_code +from IPython.utils import py3compat + +# Define ipython command line name +if py3compat.PY3: + ipy_cmd = 'ipython3 ' +else: + ipy_cmd = 'ipython ' #----------------------------------------------------------------------------- # Classes and functions @@ -165,7 +172,7 @@ class TestsBase(object): def call(self, parameters, raise_on_error=True): - stdout, stderr, retcode = get_output_error_code(parameters) + stdout, stderr, retcode = get_output_error_code(ipy_cmd + parameters) if retcode != 0 and raise_on_error: raise OSError(stderr) return stdout, stderr diff --git a/IPython/nbconvert/tests/test_nbconvertapp.py b/IPython/nbconvert/tests/test_nbconvertapp.py index 4f60385..855cb4f 100644 --- a/IPython/nbconvert/tests/test_nbconvertapp.py +++ b/IPython/nbconvert/tests/test_nbconvertapp.py @@ -16,7 +16,6 @@ Contains tests for the nbconvertapp import os from .base import TestsBase -from IPython.utils import py3compat from IPython.testing import decorators as dec @@ -24,12 +23,6 @@ from IPython.testing import decorators as dec # Constants #----------------------------------------------------------------------------- -# Define ipython commandline name -if py3compat.PY3: - IPYTHON = 'ipython3' -else: - IPYTHON = 'ipython' - #----------------------------------------------------------------------------- # Classes and functions @@ -44,7 +37,7 @@ class TestNbConvertApp(TestsBase): Will help show if no notebooks are specified? """ with self.create_temp_cwd(): - out, err = self.call(IPYTHON + ' nbconvert', raise_on_error=False) + out, err = self.call('nbconvert', raise_on_error=False) assert "see '--help-all'" in out @@ -53,8 +46,7 @@ class TestNbConvertApp(TestsBase): Do search patterns work for notebook names? """ with self.create_temp_cwd(['notebook*.ipynb']): - self.call(IPYTHON + ' nbconvert --to="python"' - ' --notebooks=*.ipynb') + self.call('nbconvert --to="python" --notebooks=*.ipynb') assert os.path.isfile('notebook1.py') assert os.path.isfile('notebook2.py') @@ -65,7 +57,7 @@ class TestNbConvertApp(TestsBase): """ with self.create_temp_cwd(): self.copy_files_to(['notebook*.ipynb'], 'subdir/') - self.call(IPYTHON + ' nbconvert --to="python"' + self.call('nbconvert --to="python"' ' --notebooks=%s' % os.path.join('subdir', '*.ipynb')) assert os.path.isfile('notebook1.py') assert os.path.isfile('notebook2.py') @@ -76,8 +68,7 @@ class TestNbConvertApp(TestsBase): Do explicit notebook names work? """ with self.create_temp_cwd(['notebook*.ipynb']): - self.call(IPYTHON + ' nbconvert --to="python"' - ' --notebooks=notebook2.ipynb') + self.call('nbconvert --to="python" --notebooks=notebook2.ipynb') assert not os.path.isfile('notebook1.py') assert os.path.isfile('notebook2.py') @@ -89,8 +80,8 @@ class TestNbConvertApp(TestsBase): Do post processors work? """ with self.create_temp_cwd(['notebook1.ipynb']): - self.call(IPYTHON + ' nbconvert --to="latex" notebook1' - ' --post="PDF" --PDFPostProcessor.verbose=True') + self.call('nbconvert --to="latex" notebook1' + ' --post="PDF" --PDFPostProcessor.verbose=True') assert os.path.isfile('notebook1.tex') print("\n\n\t" + "\n\t".join([f for f in os.listdir('.') if os.path.isfile(f)]) + "\n\n") assert os.path.isfile('notebook1.pdf') @@ -102,9 +93,8 @@ class TestNbConvertApp(TestsBase): Do export templates work? """ with self.create_temp_cwd(['notebook2.ipynb']): - self.call(IPYTHON + ' nbconvert --to=slides' - ' --notebooks=notebook2.ipynb' - ' --template=reveal') + self.call('nbconvert --to=slides --notebooks=notebook2.ipynb' + ' --template=reveal') assert os.path.isfile('notebook2.slides.html') with open('notebook2.slides.html') as f: assert '/reveal.css' in f.read() @@ -115,7 +105,7 @@ class TestNbConvertApp(TestsBase): Can a search pattern be used along with matching explicit notebook names? """ with self.create_temp_cwd(['notebook*.ipynb']): - self.call(IPYTHON + ' nbconvert --to="python" --notebooks=' + self.call('nbconvert --to="python" --notebooks=' '*.ipynb,notebook1.ipynb,notebook2.ipynb') assert os.path.isfile('notebook1.py') assert os.path.isfile('notebook2.py') @@ -126,7 +116,7 @@ class TestNbConvertApp(TestsBase): Can explicit notebook names be used and then a matching search pattern? """ with self.create_temp_cwd(['notebook*.ipynb']): - self.call(IPYTHON + ' nbconvert --to="python" --notebooks=' + self.call('nbconvert --to="python" --notebooks=' 'notebook1.ipynb,notebook2.ipynb,*.ipynb') assert os.path.isfile('notebook1.py') assert os.path.isfile('notebook2.py') @@ -137,7 +127,7 @@ class TestNbConvertApp(TestsBase): Does the default config work? """ with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py']): - self.call(IPYTHON + ' nbconvert') + self.call('nbconvert') assert os.path.isfile('notebook1.py') assert not os.path.isfile('notebook2.py') @@ -149,6 +139,6 @@ class TestNbConvertApp(TestsBase): with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py', 'override.py']): - self.call(IPYTHON + ' nbconvert --config="override.py"') + self.call('nbconvert --config="override.py"') assert not os.path.isfile('notebook1.py') assert os.path.isfile('notebook2.py')