Show More
@@ -521,14 +521,8 b' class NotebookApp(BaseIPythonApplication):' | |||||
521 | # If we receive a non-absolute path, make it absolute. |
|
521 | # If we receive a non-absolute path, make it absolute. | |
522 | self.notebook_dir = os.path.abspath(new) |
|
522 | self.notebook_dir = os.path.abspath(new) | |
523 | return |
|
523 | return | |
524 |
if |
|
524 | if not os.path.isdir(new): | |
525 |
raise TraitError("notebook dir %r |
|
525 | raise TraitError("No such notebook dir: %r" % new) | |
526 | if not os.path.exists(new): |
|
|||
527 | self.log.info("Creating notebook dir %s", new) |
|
|||
528 | try: |
|
|||
529 | os.mkdir(new) |
|
|||
530 | except: |
|
|||
531 | raise TraitError("Couldn't create notebook dir %r" % new) |
|
|||
532 |
|
526 | |||
533 | # setting App.notebook_dir implies setting notebook and kernel dirs as well |
|
527 | # setting App.notebook_dir implies setting notebook and kernel dirs as well | |
534 | self.config.FileNotebookManager.notebook_dir = new |
|
528 | self.config.FileNotebookManager.notebook_dir = new |
@@ -51,11 +51,12 b' def test_nb_dir():' | |||||
51 | app = NotebookApp(notebook_dir=td) |
|
51 | app = NotebookApp(notebook_dir=td) | |
52 | nt.assert_equal(app.notebook_dir, td) |
|
52 | nt.assert_equal(app.notebook_dir, td) | |
53 |
|
53 | |||
54 | def test_create_nb_dir(): |
|
54 | def test_no_create_nb_dir(): | |
55 | with TemporaryDirectory() as td: |
|
55 | with TemporaryDirectory() as td: | |
56 | nbdir = os.path.join(td, 'notebooks') |
|
56 | nbdir = os.path.join(td, 'notebooks') | |
57 |
app = NotebookApp( |
|
57 | app = NotebookApp() | |
58 | nt.assert_equal(app.notebook_dir, nbdir) |
|
58 | with nt.assert_raises(TraitError): | |
|
59 | app.notebook_dir = nbdir | |||
59 |
|
60 | |||
60 | def test_missing_nb_dir(): |
|
61 | def test_missing_nb_dir(): | |
61 | with TemporaryDirectory() as td: |
|
62 | with TemporaryDirectory() as td: |
General Comments 0
You need to be logged in to leave comments.
Login now