|
18 | 18 |
|
19 | 19 | from jupyter_core import paths
|
20 | 20 | from jupyter_core.paths import (
|
| 21 | + UF_HIDDEN, |
| 22 | + _win32_restrict_file_to_user_ctypes, |
| 23 | + exists, |
21 | 24 | is_file_hidden,
|
22 | 25 | is_hidden,
|
| 26 | + issue_insecure_write_warning, |
23 | 27 | jupyter_config_dir,
|
24 | 28 | jupyter_config_path,
|
25 | 29 | jupyter_data_dir,
|
@@ -428,6 +432,14 @@ def test_is_hidden():
|
428 | 432 | assert not is_file_hidden(subdir56)
|
429 | 433 | assert not is_file_hidden(subdir56, os.stat(subdir56))
|
430 | 434 |
|
| 435 | + assert not is_file_hidden(os.path.join(root, "does_not_exist")) |
| 436 | + subdir78 = os.path.join(root, "subdir7", "subdir8") |
| 437 | + os.makedirs(subdir78) |
| 438 | + assert not is_hidden(subdir78, root) |
| 439 | + if hasattr(os, "chflags"): |
| 440 | + os.chflags(subdir78, UF_HIDDEN) |
| 441 | + assert is_hidden(subdir78, root) |
| 442 | + |
431 | 443 |
|
432 | 444 | @pytest.mark.skipif(
|
433 | 445 | not (
|
@@ -486,6 +498,11 @@ def test_is_hidden_win32_pypy():
|
486 | 498 | assert "hidden files are not detectable on this system" in str(w[-1].message)
|
487 | 499 |
|
488 | 500 |
|
| 501 | +@pytest.mark.skipif(sys.platform != "win32", reason="only runs on windows") |
| 502 | +def test_win32_restrict_file_to_user_ctypes(tmp_path): |
| 503 | + _win32_restrict_file_to_user_ctypes(str(tmp_path)) |
| 504 | + |
| 505 | + |
489 | 506 | @pytest.mark.skipif(sys.platform != "win32", reason="only runs on windows")
|
490 | 507 | def test_secure_write_win32():
|
491 | 508 | def fetch_win32_permissions(filename):
|
@@ -553,3 +570,13 @@ def test_secure_write_unix():
|
553 | 570 | assert f.read() == "test 2"
|
554 | 571 | finally:
|
555 | 572 | shutil.rmtree(directory)
|
| 573 | + |
| 574 | + |
| 575 | +def test_exists(tmpdir): |
| 576 | + assert exists(str(tmpdir)) |
| 577 | + |
| 578 | + |
| 579 | +def test_insecure_write_warning(): |
| 580 | + with warnings.catch_warnings(): |
| 581 | + warnings.simplefilter("ignore", UserWarning) |
| 582 | + issue_insecure_write_warning() |
0 commit comments