diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index 8e448dc30c..ca0c38a1ca 100644 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -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 diff --git a/tests/test_serverapp.py b/tests/test_serverapp.py index 89225e50bb..2fe346fc37 100644 --- a/tests/test_serverapp.py +++ b/tests/test_serverapp.py @@ -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): @@ -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):