Skip to content

Commit 9a976bb

Browse files
authored
Add more path tests (#316)
* add more path tests * lint and fix fixture
1 parent 51b8a12 commit 9a976bb

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

jupyter_core/tests/test_paths.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818

1919
from jupyter_core import paths
2020
from jupyter_core.paths import (
21+
UF_HIDDEN,
22+
_win32_restrict_file_to_user_ctypes,
23+
exists,
2124
is_file_hidden,
2225
is_hidden,
26+
issue_insecure_write_warning,
2327
jupyter_config_dir,
2428
jupyter_config_path,
2529
jupyter_data_dir,
@@ -428,6 +432,14 @@ def test_is_hidden():
428432
assert not is_file_hidden(subdir56)
429433
assert not is_file_hidden(subdir56, os.stat(subdir56))
430434

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+
431443

432444
@pytest.mark.skipif(
433445
not (
@@ -486,6 +498,11 @@ def test_is_hidden_win32_pypy():
486498
assert "hidden files are not detectable on this system" in str(w[-1].message)
487499

488500

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+
489506
@pytest.mark.skipif(sys.platform != "win32", reason="only runs on windows")
490507
def test_secure_write_win32():
491508
def fetch_win32_permissions(filename):
@@ -553,3 +570,13 @@ def test_secure_write_unix():
553570
assert f.read() == "test 2"
554571
finally:
555572
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

Comments
 (0)