Skip to content

Commit 2f5969a

Browse files
committed
Fix preferred-dir tests
1 parent 99d51c4 commit 2f5969a

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

tests/test_serverapp.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ def test_urls(config, public_url, local_url, connection_url):
256256

257257
# Preferred dir tests
258258
# ----------------------------------------------------------------------------
259+
@pytest.mark.filterwarnings("ignore::FutureWarning")
259260
def test_valid_preferred_dir(tmp_path, jp_configurable_serverapp):
260261
path = str(tmp_path)
261262
app = jp_configurable_serverapp(root_dir=path, preferred_dir=path)
@@ -264,6 +265,7 @@ def test_valid_preferred_dir(tmp_path, jp_configurable_serverapp):
264265
assert app.root_dir == app.preferred_dir
265266

266267

268+
@pytest.mark.filterwarnings("ignore::FutureWarning")
267269
def test_valid_preferred_dir_is_root_subdir(tmp_path, jp_configurable_serverapp):
268270
path = str(tmp_path)
269271
path_subdir = str(tmp_path / "subdir")
@@ -284,7 +286,7 @@ def test_valid_preferred_dir_does_not_exist(tmp_path, jp_configurable_serverapp)
284286

285287

286288
# This tests some deprecated behavior as well
287-
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
289+
@pytest.mark.filterwarnings("ignore::FutureWarning")
288290
@pytest.mark.parametrize(
289291
"root_dir_loc,preferred_dir_loc",
290292
[
@@ -335,9 +337,8 @@ def test_preferred_dir_validation(
335337
kwargs["argv"] = argv # type:ignore
336338

337339
if root_dir_loc == "default" and preferred_dir_loc != "default": # error expected
338-
app = jp_configurable_serverapp(**kwargs)
339-
with pytest.raises(TraitError):
340-
app.contents_manager.preferred_dir
340+
with pytest.raises(SystemExit):
341+
jp_configurable_serverapp(**kwargs)
341342
else:
342343
app = jp_configurable_serverapp(**kwargs)
343344
assert app.root_dir == expected_root_dir
@@ -368,18 +369,14 @@ def test_invalid_preferred_dir_does_not_exist_set(tmp_path, jp_configurable_serv
368369
assert "No such preferred dir:" in str(error)
369370

370371

371-
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
372+
@pytest.mark.filterwarnings("ignore::FutureWarning")
372373
def test_invalid_preferred_dir_not_root_subdir(tmp_path, jp_configurable_serverapp):
373374
path = str(tmp_path / "subdir")
374375
os.makedirs(path, exist_ok=True)
375376
not_subdir_path = str(tmp_path)
376377

377-
with pytest.raises(TraitError) as error:
378-
app = jp_configurable_serverapp(root_dir=path, preferred_dir=not_subdir_path)
379-
# reading the value triggers default generator:
380-
app.contents_manager.preferred_dir
381-
382-
assert "is outside root contents directory" in str(error)
378+
with pytest.raises(SystemExit):
379+
jp_configurable_serverapp(root_dir=path, preferred_dir=not_subdir_path)
383380

384381

385382
def test_invalid_preferred_dir_not_root_subdir_set(tmp_path, jp_configurable_serverapp):
@@ -399,8 +396,8 @@ def test_absolute_preferred_dir_not_root_subdir_set(tmp_path, jp_configurable_se
399396
os.makedirs(path, exist_ok=True)
400397
not_subdir_path = str(tmp_path)
401398

402-
app = jp_configurable_serverapp(root_dir=path)
403399
with pytest.raises(TraitError) as error:
400+
app = jp_configurable_serverapp(root_dir=path)
404401
app.contents_manager.preferred_dir = not_subdir_path
405402

406403
if os.name == "nt":

0 commit comments

Comments
 (0)