Skip to content

Commit

Permalink
Add the root_dir value to the logging message in case of non complian…
Browse files Browse the repository at this point in the history
…t preferred_dir (#804)
  • Loading branch information
echarles authored Apr 26, 2022
1 parent f7f49fa commit c51f5a8
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
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,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
Original file line number Diff line number Diff line change
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 c51f5a8

Please sign in to comment.