From 9c082528a3ab94de42b65d00d117813a466b902e Mon Sep 17 00:00:00 2001 From: Eric Charles Date: Tue, 26 Apr 2022 14:22:58 +0200 Subject: [PATCH] Backport PR #804: Add the root_dir value to the logging message in case of non compliant preferred_dir --- jupyter_server/serverapp.py | 5 ++++- tests/test_serverapp.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) 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):