diff --git a/IPython/html/notebookapp.py b/IPython/html/notebookapp.py index cbeef79..5ec9414 100644 --- a/IPython/html/notebookapp.py +++ b/IPython/html/notebookapp.py @@ -521,14 +521,8 @@ class NotebookApp(BaseIPythonApplication): # If we receive a non-absolute path, make it absolute. self.notebook_dir = os.path.abspath(new) return - if os.path.exists(new) and not os.path.isdir(new): - raise TraitError("notebook dir %r is not a directory" % new) - if not os.path.exists(new): - self.log.info("Creating notebook dir %s", new) - try: - os.mkdir(new) - except: - raise TraitError("Couldn't create notebook dir %r" % new) + if not os.path.isdir(new): + raise TraitError("No such notebook dir: %r" % new) # setting App.notebook_dir implies setting notebook and kernel dirs as well self.config.FileNotebookManager.notebook_dir = new diff --git a/IPython/html/tests/test_notebookapp.py b/IPython/html/tests/test_notebookapp.py index 849e211..408bc00 100644 --- a/IPython/html/tests/test_notebookapp.py +++ b/IPython/html/tests/test_notebookapp.py @@ -51,11 +51,12 @@ def test_nb_dir(): app = NotebookApp(notebook_dir=td) nt.assert_equal(app.notebook_dir, td) -def test_create_nb_dir(): +def test_no_create_nb_dir(): with TemporaryDirectory() as td: nbdir = os.path.join(td, 'notebooks') - app = NotebookApp(notebook_dir=nbdir) - nt.assert_equal(app.notebook_dir, nbdir) + app = NotebookApp() + with nt.assert_raises(TraitError): + app.notebook_dir = nbdir def test_missing_nb_dir(): with TemporaryDirectory() as td: