From fa59d6f3e8ac6fa14d5ee4f82b8a6fd42f20a08d 2013-08-01 19:21:22 From: Jonathan Frederic Date: 2013-08-01 19:21:22 Subject: [PATCH] Fixed double single apostrophe --- diff --git a/IPython/nbconvert/tests/test_nbconvertapp.py b/IPython/nbconvert/tests/test_nbconvertapp.py index 9025ea4..45bff41 100644 --- a/IPython/nbconvert/tests/test_nbconvertapp.py +++ b/IPython/nbconvert/tests/test_nbconvertapp.py @@ -37,7 +37,7 @@ class TestNbConvertApp(TestsBase): Will help show if no notebooks are specified? """ with self.create_temp_cwd(): - out, err = self.call('nbconvert --NbConvertApp.log_level="WARN"'', raise_on_error=False) + out, err = self.call('nbconvert --NbConvertApp.log_level="WARN"', raise_on_error=False) assert "see '--help-all'" in out @@ -46,7 +46,7 @@ class TestNbConvertApp(TestsBase): Do search patterns work for notebook names? """ with self.create_temp_cwd(['notebook*.ipynb']): - self.call('nbconvert --to="python" --notebooks=\'["*.ipynb"]\' --NbConvertApp.log_level="WARN"'') + self.call('nbconvert --to="python" --notebooks=\'["*.ipynb"]\' --NbConvertApp.log_level="WARN"') assert os.path.isfile('notebook1.py') assert os.path.isfile('notebook2.py') @@ -57,7 +57,7 @@ class TestNbConvertApp(TestsBase): """ with self.create_temp_cwd(): self.copy_files_to(['notebook*.ipynb'], 'subdir/') - self.call('nbconvert --to="python" --NbConvertApp.log_level="WARN"' --notebooks=' + self.call('nbconvert --to="python" --NbConvertApp.log_level="WARN" --notebooks=' '\'["%s"]\'' % os.path.join('subdir', '*.ipynb')) assert os.path.isfile('notebook1.py') assert os.path.isfile('notebook2.py') @@ -68,7 +68,7 @@ class TestNbConvertApp(TestsBase): Do explicit notebook names work? """ with self.create_temp_cwd(['notebook*.ipynb']): - self.call('nbconvert --NbConvertApp.log_level="WARN"' --to="python" --notebooks=' + self.call('nbconvert --NbConvertApp.log_level="WARN" --to="python" --notebooks=' '\'["notebook2.ipynb"]\'') assert not os.path.isfile('notebook1.py') assert os.path.isfile('notebook2.py') @@ -81,7 +81,7 @@ class TestNbConvertApp(TestsBase): Do post processors work? """ with self.create_temp_cwd(['notebook1.ipynb']): - self.call('nbconvert --NbConvertApp.log_level="WARN"' --to="latex" notebook1' + self.call('nbconvert --NbConvertApp.log_level="WARN" --to="latex" notebook1' ' --post="PDF" --PDFPostProcessor.verbose=True') assert os.path.isfile('notebook1.tex') assert os.path.isfile('notebook1.pdf') @@ -93,7 +93,7 @@ class TestNbConvertApp(TestsBase): Do export templates work? """ with self.create_temp_cwd(['notebook2.ipynb']): - self.call('nbconvert --NbConvertApp.log_level="WARN"' --to=slides --notebooks=' + self.call('nbconvert --NbConvertApp.log_level="WARN" --to=slides --notebooks=' '\'["notebook2.ipynb"]\' --template=reveal') assert os.path.isfile('notebook2.slides.html') with open('notebook2.slides.html') as f: @@ -105,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('nbconvert --NbConvertApp.log_level="WARN"' --to="python" --notebooks=' + self.call('nbconvert --NbConvertApp.log_level="WARN" --to="python" --notebooks=' '\'["*.ipynb","notebook1.ipynb","notebook2.ipynb"]\'') assert os.path.isfile('notebook1.py') assert os.path.isfile('notebook2.py') @@ -116,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('nbconvert --NbConvertApp.log_level="WARN"' --to="python" --notebooks=' + self.call('nbconvert --NbConvertApp.log_level="WARN" --to="python" --notebooks=' '\'["notebook1.ipynb","notebook2.ipynb","*.ipynb"]\'') assert os.path.isfile('notebook1.py') assert os.path.isfile('notebook2.py') @@ -127,7 +127,7 @@ class TestNbConvertApp(TestsBase): Does the default config work? """ with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py']): - self.call('nbconvert --NbConvertApp.log_level="WARN"'') + self.call('nbconvert --NbConvertApp.log_level="WARN"') assert os.path.isfile('notebook1.py') assert not os.path.isfile('notebook2.py') @@ -139,6 +139,6 @@ class TestNbConvertApp(TestsBase): with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py', 'override.py']): - self.call('nbconvert --NbConvertApp.log_level="WARN"' --config="override.py"') + self.call('nbconvert --NbConvertApp.log_level="WARN" --config="override.py"') assert not os.path.isfile('notebook1.py') assert os.path.isfile('notebook2.py') diff --git a/IPython/nbconvert/tests/test_nbconvertapp.py.orig b/IPython/nbconvert/tests/test_nbconvertapp.py.orig new file mode 100644 index 0000000..cf963df --- /dev/null +++ b/IPython/nbconvert/tests/test_nbconvertapp.py.orig @@ -0,0 +1,201 @@ +""" +Contains tests for the nbconvertapp +""" +#----------------------------------------------------------------------------- +#Copyright (c) 2013, the IPython Development Team. +# +#Distributed under the terms of the Modified BSD License. +# +#The full license is in the file COPYING.txt, distributed with this software. +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Imports +#----------------------------------------------------------------------------- + +import os +from .base import TestsBase + +from IPython.testing import decorators as dec + + +#----------------------------------------------------------------------------- +# Constants +#----------------------------------------------------------------------------- + + +#----------------------------------------------------------------------------- +# Classes and functions +#----------------------------------------------------------------------------- + +class TestNbConvertApp(TestsBase): + """Collection of NbConvertApp tests""" + + + def test_notebook_help(self): + """ + Will help show if no notebooks are specified? + """ + with self.create_temp_cwd(): +<<<<<<< HEAD + out, err = self.call('nbconvert', raise_on_error=False) + assert "see '--help-all'" in out +======= + assert "see '--help-all'" in self.call([IPYTHON, 'nbconvert', + '--NbConvertApp.log_level="WARN"']) +>>>>>>> Silence INFO logging in test output + + + def test_glob(self): + """ + Do search patterns work for notebook names? + """ + with self.create_temp_cwd(['notebook*.ipynb']): +<<<<<<< HEAD + self.call('nbconvert --to="python" --notebooks=\'["*.ipynb"]\'') +======= + assert not 'error' in self.call([IPYTHON, 'nbconvert', + '--to="python"', '--notebooks=["*.ipynb"]', + '--NbConvertApp.log_level="WARN"']).lower() +>>>>>>> Silence INFO logging in test output + assert os.path.isfile('notebook1.py') + assert os.path.isfile('notebook2.py') + + + def test_glob_subdir(self): + """ + Do search patterns work for subdirectory notebook names? + """ + with self.create_temp_cwd(): + self.copy_files_to(['notebook*.ipynb'], 'subdir/') +<<<<<<< HEAD + self.call('nbconvert --to="python" --notebooks=' + '\'["%s"]\'' % os.path.join('subdir', '*.ipynb')) +======= + assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="python"', + '--notebooks=["%s"]' % os.path.join('subdir', '*.ipynb'), + '--NbConvertApp.log_level="WARN"']).lower() +>>>>>>> Silence INFO logging in test output + assert os.path.isfile('notebook1.py') + assert os.path.isfile('notebook2.py') + + + def test_explicit(self): + """ + Do explicit notebook names work? + """ + with self.create_temp_cwd(['notebook*.ipynb']): +<<<<<<< HEAD + self.call('nbconvert --to="python" --notebooks=' + '\'["notebook2.ipynb"]\'') +======= + assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="python"', + '--notebooks=["notebook2.ipynb"]', + '--NbConvertApp.log_level="WARN"']).lower() +>>>>>>> Silence INFO logging in test output + assert not os.path.isfile('notebook1.py') + assert os.path.isfile('notebook2.py') + + + @dec.onlyif_cmds_exist('pdflatex') + @dec.onlyif_cmds_exist('pandoc') + def test_post_processor(self): + """ + Do post processors work? + """ + with self.create_temp_cwd(['notebook1.ipynb']): +<<<<<<< HEAD + self.call('nbconvert --to="latex" notebook1' + ' --post="PDF" --PDFPostProcessor.verbose=True') +======= + assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="latex"', + 'notebook1', '--post="PDF"', '--PDFPostProcessor.verbose=True', + '--NbConvertApp.log_level="WARN"']).lower() +>>>>>>> Silence INFO logging in test output + assert os.path.isfile('notebook1.tex') + assert os.path.isfile('notebook1.pdf') + + + @dec.onlyif_cmds_exist('pandoc') + def test_template(self): + """ + Do export templates work? + """ + with self.create_temp_cwd(['notebook2.ipynb']): +<<<<<<< HEAD + self.call('nbconvert --to=slides --notebooks=' + '\'["notebook2.ipynb"]\' --template=reveal') +======= + assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to=slides', + '--notebooks=["notebook2.ipynb"]', '--template=reveal', + '--NbConvertApp.log_level="WARN"']).lower() +>>>>>>> Silence INFO logging in test output + assert os.path.isfile('notebook2.slides.html') + with open('notebook2.slides.html') as f: + assert '/reveal.css' in f.read() + + + def test_glob_explicit(self): + """ + Can a search pattern be used along with matching explicit notebook names? + """ + with self.create_temp_cwd(['notebook*.ipynb']): +<<<<<<< HEAD + self.call('nbconvert --to="python" --notebooks=' + '\'["*.ipynb","notebook1.ipynb","notebook2.ipynb"]\'') +======= + assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="python"', + '--notebooks=["*.ipynb", "notebook1.ipynb", "notebook2.ipynb"]', + '--NbConvertApp.log_level="WARN"']).lower() +>>>>>>> Silence INFO logging in test output + assert os.path.isfile('notebook1.py') + assert os.path.isfile('notebook2.py') + + + def test_explicit_glob(self): + """ + Can explicit notebook names be used and then a matching search pattern? + """ + with self.create_temp_cwd(['notebook*.ipynb']): +<<<<<<< HEAD + self.call('nbconvert --to="python" --notebooks=' + '\'["notebook1.ipynb","notebook2.ipynb","*.ipynb"]\'') +======= + assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="python"', + '--notebooks=["notebook1.ipynb", "notebook2.ipynb", "*.ipynb"]', + '--NbConvertApp.log_level="WARN"']).lower() +>>>>>>> Silence INFO logging in test output + assert os.path.isfile('notebook1.py') + assert os.path.isfile('notebook2.py') + + + def test_default_config(self): + """ + Does the default config work? + """ + with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py']): +<<<<<<< HEAD + self.call('nbconvert') +======= + assert not 'error' in self.call([IPYTHON, 'nbconvert', + '--NbConvertApp.log_level="WARN"']).lower() +>>>>>>> Silence INFO logging in test output + assert os.path.isfile('notebook1.py') + assert not os.path.isfile('notebook2.py') + + + def test_override_config(self): + """ + Can the default config be overriden? + """ + with self.create_temp_cwd(['notebook*.ipynb', + 'ipython_nbconvert_config.py', + 'override.py']): +<<<<<<< HEAD + self.call('nbconvert --config="override.py"') +======= + assert not 'error' in self.call([IPYTHON, 'nbconvert', '--config="override.py"', + '--NbConvertApp.log_level="WARN"']).lower() +>>>>>>> Silence INFO logging in test output + assert not os.path.isfile('notebook1.py') + assert os.path.isfile('notebook2.py')