Skip to content

Commit c51f5a8

Browse files
authored
Add the root_dir value to the logging message in case of non compliant preferred_dir (#804)
1 parent f7f49fa commit c51f5a8

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

jupyter_server/serverapp.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1605,7 +1605,10 @@ def _preferred_dir_validate(self, proposal):
16051605
# preferred_dir must be equal or a subdir of root_dir
16061606
if not value.startswith(self.root_dir):
16071607
raise TraitError(
1608-
trans.gettext("preferred_dir must be equal or a subdir of root_dir: '%r'") % value
1608+
trans.gettext(
1609+
"preferred_dir must be equal or a subdir of root_dir. preferred_dir: '%r' root_dir: '%r'"
1610+
)
1611+
% (value, self.root_dir)
16091612
)
16101613

16111614
return value

tests/test_serverapp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def test_invalid_preferred_dir_not_root_subdir(tmp_path, jp_configurable_servera
309309
with pytest.raises(TraitError) as error:
310310
app = jp_configurable_serverapp(root_dir=path, preferred_dir=not_subdir_path)
311311

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

314314

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

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

326326

327327
def test_observed_root_dir_updates_preferred_dir(tmp_path, jp_configurable_serverapp):

0 commit comments

Comments
 (0)