diff --git a/IPython/nbconvert/tests/base.py b/IPython/nbconvert/tests/base.py index a19372c..23f9123 100644 --- a/IPython/nbconvert/tests/base.py +++ b/IPython/nbconvert/tests/base.py @@ -13,13 +13,16 @@ Contains base test class for nbconvert # Imports #----------------------------------------------------------------------------- +import io import os import glob import shutil import unittest import IPython +from IPython.nbformat import current from IPython.utils.tempdir import TemporaryWorkingDirectory +from IPython.utils.path import get_ipython_package_dir from IPython.utils.process import get_output_error_code from IPython.testing.tools import get_ipython_cmd @@ -110,6 +113,12 @@ class TestsBase(unittest.TestCase): #Return directory handler return temp_dir + + def create_empty_notebook(self, path): + nb = current.new_notebook() + nb.worksheets.append(current.new_worksheet()) + with io.open(path, 'w', encoding='utf-8') as f: + current.write(nb, f, 'json') def copy_files_to(self, copy_filenames, dest='.'): @@ -130,7 +139,7 @@ class TestsBase(unittest.TestCase): #Build a path using the IPython directory and the relative path we just #found. - path = IPython.__path__[0] + path = get_ipython_package_dir() for name in names: path = os.path.join(path, name) return path diff --git "a/IPython/nbconvert/tests/files/nb1_an\303\241lisis.ipynb" "b/IPython/nbconvert/tests/files/nb1_an\303\241lisis.ipynb" deleted file mode 100644 index 35524ef..0000000 --- "a/IPython/nbconvert/tests/files/nb1_an\303\241lisis.ipynb" +++ /dev/null @@ -1,22 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/IPython/nbconvert/tests/test_nbconvertapp.py b/IPython/nbconvert/tests/test_nbconvertapp.py index c3827e1..62601c4 100644 --- a/IPython/nbconvert/tests/test_nbconvertapp.py +++ b/IPython/nbconvert/tests/test_nbconvertapp.py @@ -189,7 +189,8 @@ class TestNbConvertApp(TestsBase): """ Can notebook names include accents? """ - with self.create_temp_cwd(['nb*.ipynb']): + with self.create_temp_cwd(): + self.create_empty_notebook(u'nb1_análisis.ipynb') self.call('nbconvert --log-level 0 --to python nb1_*') assert os.path.isfile(u'nb1_análisis.py') @@ -199,7 +200,8 @@ class TestNbConvertApp(TestsBase): """ Generate PDFs if notebooks have an accent in their name? """ - with self.create_temp_cwd(['nb*.ipynb']): + with self.create_temp_cwd(): + self.create_empty_notebook(u'nb1_análisis.ipynb') o,e = self.call('nbconvert --log-level 0 --to latex ' '"nb1_*" --post PDF ' '--PDFPostProcessor.verbose=True')