From 719a8875bc3838dd05d9ed81bb23906662f6f506 Mon Sep 17 00:00:00 2001 From: M Pacer Date: Tue, 11 Sep 2018 13:03:21 -0700 Subject: [PATCH] add test for old behaviour where kernel_name="" uses file specified In order to not use the default "python" behvaiour, I set the kernel to be "python3". However, that means this can only work if we have a python3 kernel available. --- nbconvert/preprocessors/tests/test_execute.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/nbconvert/preprocessors/tests/test_execute.py b/nbconvert/preprocessors/tests/test_execute.py index 2ccf7e52a..ccd5076f6 100644 --- a/nbconvert/preprocessors/tests/test_execute.py +++ b/nbconvert/preprocessors/tests/test_execute.py @@ -21,6 +21,8 @@ from .base import PreprocessorTestsBase from ..execute import ExecutePreprocessor, CellExecutionError, executenb, find_kernel_name +from jupyter_client.kernelspec import KernelSpecManager + from nbconvert.filters import strip_ansi from testpath import modified_env from ipython_genutils.py3compat import string_types @@ -151,6 +153,19 @@ def test_empty_path(self): res['metadata']['path'] = '' input_nb, output_nb = self.run_notebook(filename, {}, res) self.assert_notebooks_equal(input_nb, output_nb) + + @pytest.mark.xfail("python3" not in KernelSpecManager().find_kernel_specs(), + reason="requires a python3 kernelspec") + def test_empty_kernel_name(self): + """Can kernel in nb metadata be found when an empty string is passed? + + Note: this pattern should be discouraged in practice. + Passing in no kernel_name to ExecutePreprocessor is preferable. + """ + filename = os.path.join(current_dir, 'files', 'UnicodePy3.ipynb') + res = self.build_resources() + input_nb, output_nb = self.run_notebook(filename, {"kernel_name": ""}, res) + self.assert_notebooks_equal(input_nb, output_nb) def test_disable_stdin(self): """Test disabling standard input"""