Merge pull request #1168 from minrk/allow-root-notebook-dir

allow notebook-dir to be root
This commit is contained in:
Thomas Kluyver 2016-03-04 11:50:45 +00:00
commit 2018e800dc
2 changed files with 10 additions and 0 deletions

View File

@ -805,6 +805,11 @@ class NotebookApp(JupyterApp):
def _notebook_dir_validate(self, value, trait):
# Strip any trailing slashes
# *except* if it's root
_, path = os.path.splitdrive(value)
if path == os.sep:
return value
value = value.rstrip(os.sep)
if not os.path.isabs(value):

View File

@ -68,6 +68,11 @@ def test_nb_dir_with_slash():
app = NotebookApp(notebook_dir=td)
nt.assert_false(app.notebook_dir.endswith("/"))
def test_nb_dir_root():
root = os.path.abspath(os.sep) # gets the right value on Windows, Posix
app = NotebookApp(notebook_dir=root)
nt.assert_equal(app.notebook_dir, root)
def test_generate_config():
with TemporaryDirectory() as td:
app = NotebookApp(config_dir=td)