|
18 | 18 | list_running_servers,
|
19 | 19 | random_ports,
|
20 | 20 | )
|
| 21 | +from jupyter_server.services.contents.filemanager import ( |
| 22 | + AsyncFileContentsManager, |
| 23 | + FileContentsManager, |
| 24 | +) |
21 | 25 | from jupyter_server.utils import pathname2url, urljoin
|
22 | 26 |
|
23 | 27 |
|
| 28 | +@pytest.fixture(params=[FileContentsManager, AsyncFileContentsManager]) |
| 29 | +def jp_file_contents_manager_class(request, tmp_path): |
| 30 | + return request.param |
| 31 | + |
| 32 | + |
24 | 33 | def test_help_output():
|
25 | 34 | """jupyter server --help-all works"""
|
26 | 35 | check_help_all_output("jupyter_server")
|
@@ -291,11 +300,28 @@ def test_valid_preferred_dir_does_not_exist(tmp_path, jp_configurable_serverapp)
|
291 | 300 | path = str(tmp_path)
|
292 | 301 | path_subdir = str(tmp_path / "subdir")
|
293 | 302 | with pytest.raises(TraitError) as error:
|
294 |
| - app = jp_configurable_serverapp(root_dir=path, preferred_dir=path_subdir) |
| 303 | + jp_configurable_serverapp(root_dir=path, preferred_dir=path_subdir) |
295 | 304 |
|
296 | 305 | assert "No such preferred dir:" in str(error)
|
297 | 306 |
|
298 | 307 |
|
| 308 | +@pytest.mark.filterwarnings("ignore::DeprecationWarning") |
| 309 | +def test_preferred_dir_validation_sync_regression( |
| 310 | + tmp_path, jp_configurable_serverapp, jp_file_contents_manager_class |
| 311 | +): |
| 312 | + path = str(tmp_path) |
| 313 | + path_subdir = str(tmp_path / "subdir") |
| 314 | + os.makedirs(path_subdir, exist_ok=True) |
| 315 | + app = jp_configurable_serverapp( |
| 316 | + root_dir=path, |
| 317 | + contents_manager_class=jp_file_contents_manager_class, |
| 318 | + ) |
| 319 | + app.contents_manager.preferred_dir = path_subdir |
| 320 | + assert app.preferred_dir == path_subdir |
| 321 | + assert app.preferred_dir.startswith(app.root_dir) |
| 322 | + assert app.contents_manager.preferred_dir == "subdir" |
| 323 | + |
| 324 | + |
299 | 325 | # This tests some deprecated behavior as well
|
300 | 326 | @pytest.mark.filterwarnings("ignore::FutureWarning")
|
301 | 327 | @pytest.mark.parametrize(
|
|
0 commit comments