Skip to content

Commit

Permalink
Backport PR jupyter-server#804: Add the root_dir value to the logging…
Browse files Browse the repository at this point in the history
… message in case of non compliant preferred_dir
  • Loading branch information
echarles authored and meeseeksmachine committed Apr 26, 2022
1 parent ffa9848 commit 9c08252
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion jupyter_server/serverapp.py
Expand Up @@ -1618,7 +1618,10 @@ def _preferred_dir_validate(self, proposal):
# preferred_dir must be equal or a subdir of root_dir
if not value.startswith(self.root_dir):
raise TraitError(
trans.gettext("preferred_dir must be equal or a subdir of root_dir: '%r'") % value
trans.gettext(
"preferred_dir must be equal or a subdir of root_dir. preferred_dir: '%r' root_dir: '%r'"
)
% (value, self.root_dir)
)

return value
Expand Down
4 changes: 2 additions & 2 deletions tests/test_serverapp.py
Expand Up @@ -309,7 +309,7 @@ def test_invalid_preferred_dir_not_root_subdir(tmp_path, jp_configurable_servera
with pytest.raises(TraitError) as error:
app = jp_configurable_serverapp(root_dir=path, preferred_dir=not_subdir_path)

assert "preferred_dir must be equal or a subdir of root_dir:" in str(error)
assert "preferred_dir must be equal or a subdir of root_dir. " in str(error)


def test_invalid_preferred_dir_not_root_subdir_set(tmp_path, jp_configurable_serverapp):
Expand All @@ -321,7 +321,7 @@ def test_invalid_preferred_dir_not_root_subdir_set(tmp_path, jp_configurable_ser
with pytest.raises(TraitError) as error:
app.preferred_dir = not_subdir_path

assert "preferred_dir must be equal or a subdir of root_dir:" in str(error)
assert "preferred_dir must be equal or a subdir of root_dir. " in str(error)


def test_observed_root_dir_updates_preferred_dir(tmp_path, jp_configurable_serverapp):
Expand Down

0 comments on commit 9c08252

Please sign in to comment.