Skip to content

Commit 1f5f64b

Browse files
Backport PR jupyter-server#804 on branch 1.x (Add the root_dir value to the logging message in case of non compliant preferred_dir) (jupyter-server#805)
Co-authored-by: Eric Charles <[email protected]>
1 parent ffa9848 commit 1f5f64b

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
@@ -1618,7 +1618,10 @@ def _preferred_dir_validate(self, proposal):
16181618
# preferred_dir must be equal or a subdir of root_dir
16191619
if not value.startswith(self.root_dir):
16201620
raise TraitError(
1621-
trans.gettext("preferred_dir must be equal or a subdir of root_dir: '%r'") % value
1621+
trans.gettext(
1622+
"preferred_dir must be equal or a subdir of root_dir. preferred_dir: '%r' root_dir: '%r'"
1623+
)
1624+
% (value, self.root_dir)
16221625
)
16231626

16241627
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)