|
6 | 6 |
|
7 | 7 | import pytest
|
8 | 8 | from jupyter_core.application import NoStart
|
| 9 | +from tornado.web import HTTPError |
9 | 10 | from traitlets import TraitError
|
10 | 11 | from traitlets.tests.utils import check_help_all_output
|
11 | 12 |
|
@@ -379,28 +380,30 @@ def test_invalid_preferred_dir_not_root_subdir(tmp_path, jp_configurable_servera
|
379 | 380 | jp_configurable_serverapp(root_dir=path, preferred_dir=not_subdir_path)
|
380 | 381 |
|
381 | 382 |
|
382 |
| -def test_invalid_preferred_dir_not_root_subdir_set(tmp_path, jp_configurable_serverapp): |
| 383 | +async def test_invalid_preferred_dir_not_root_subdir_set(tmp_path, jp_configurable_serverapp): |
383 | 384 | path = str(tmp_path / "subdir")
|
384 | 385 | os.makedirs(path, exist_ok=True)
|
385 | 386 | not_subdir_path = os.path.relpath(tmp_path, path)
|
386 | 387 |
|
387 | 388 | app = jp_configurable_serverapp(root_dir=path)
|
388 |
| - with pytest.raises(TraitError) as error: |
| 389 | + with pytest.raises(HTTPError) as error: |
389 | 390 | app.contents_manager.preferred_dir = not_subdir_path
|
| 391 | + await app.contents_manager.dir_exists(app.contents_manager.preferred_dir) |
390 | 392 |
|
391 |
| - assert "is outside root contents directory" in str(error) |
| 393 | + assert "is outside root contents directory" in str(error.value) |
392 | 394 |
|
393 | 395 |
|
394 |
| -def test_absolute_preferred_dir_not_root_subdir_set(tmp_path, jp_configurable_serverapp): |
| 396 | +async def test_absolute_preferred_dir_not_root_subdir_set(tmp_path, jp_configurable_serverapp): |
395 | 397 | path = str(tmp_path / "subdir")
|
396 | 398 | os.makedirs(path, exist_ok=True)
|
397 | 399 | not_subdir_path = str(tmp_path)
|
398 | 400 |
|
399 |
| - with pytest.raises(TraitError) as error: |
| 401 | + with pytest.raises(HTTPError) as error: |
400 | 402 | app = jp_configurable_serverapp(root_dir=path)
|
401 | 403 | app.contents_manager.preferred_dir = not_subdir_path
|
| 404 | + await app.contents_manager.dir_exists(app.contents_manager.preferred_dir) |
402 | 405 |
|
403 | 406 | if os.name == "nt":
|
404 |
| - assert "is not a relative API path" in str(error) |
| 407 | + assert "is not a relative API path" in str(error.value) |
405 | 408 | else:
|
406 |
| - assert "Preferred directory not found" in str(error) |
| 409 | + assert "Preferred directory not found" in str(error.value) |
0 commit comments