@@ -50,22 +50,8 @@ def _umask_0():
5050 os .umask (old_mask )
5151
5252
53- def symlink_skip_reason ():
54- if not pathlib .supports_symlinks : # type: ignore
55- return "no system support for symlinks"
56-
57- try :
58- with tempfile .TemporaryDirectory () as tmpdir :
59- os .symlink (__file__ , os .path .join (tmpdir , "foo.py" ))
60- except (OSError , NotImplementedError ) as e : # NotImplementedError is raised by PyPy
61- return str (e )
62- return None
63-
64-
65- symlink_skip_reason = symlink_skip_reason ()
6653only_nt = pytest .mark .skipif (condition = os .name != "nt" , reason = "test requires a Windows-compatible system" )
6754only_posix = pytest .mark .skipif (condition = os .name == "nt" , reason = "test requires a POSIX-compatible system" )
68- with_symlinks = unittest .skipIf (symlink_skip_reason , symlink_skip_reason ) # type: ignore
6955
7056
7157@pytest .fixture ()
@@ -99,14 +85,14 @@ def dirlink(src, dest):
9985 with open (join ("dirC" , "dirD" , "fileD" ), "wb" ) as f :
10086 f .write (b"this is file D\n " )
10187 os .chmod (join ("dirE" ), 0 )
102- if not symlink_skip_reason :
103- # Relative symlinks.
104- os .symlink ("fileA" , join ("linkA" ))
105- os .symlink ("non-existing" , join ("brokenLink" ))
106- dirlink ("dirB" , join ("linkB" ))
107- dirlink (os .path .join (".." , "dirB" ), join ("dirA" , "linkC" ))
108- # This one goes upwards, creating a loop.
109- dirlink (os .path .join (".." , "dirB" ), join ("dirB" , "linkD" ))
88+
89+ # Relative symlinks.
90+ os .symlink ("fileA" , join ("linkA" ))
91+ os .symlink ("non-existing" , join ("brokenLink" ))
92+ dirlink ("dirB" , join ("linkB" ))
93+ dirlink (os .path .join (".." , "dirB" ), join ("dirA" , "linkC" ))
94+ # This one goes upwards, creating a loop.
95+ dirlink (os .path .join (".." , "dirB" ), join ("dirB" , "linkD" ))
11096
11197 yield tmp_pathplus
11298
@@ -468,7 +454,6 @@ def my_mkdir(path, mode=0o777):
468454 assert (p .exists ())
469455
470456
471- @with_symlinks
472457def test_symlink_to (BASE ):
473458 P = PathPlus (BASE )
474459 target = P / "fileA"
@@ -499,10 +484,10 @@ def test_is_dir(BASE):
499484 assert not ((P / "fileA" ).is_dir ())
500485 assert not ((P / "non-existing" ).is_dir ())
501486 assert not ((P / "fileA" / "bah" ).is_dir ())
502- if not symlink_skip_reason :
503- assert not ((P / "linkA" ).is_dir ())
504- assert ((P / "linkB" ).is_dir ())
505- assert not (P / "brokenLink" ).is_dir ()
487+
488+ assert not ((P / "linkA" ).is_dir ())
489+ assert ((P / "linkB" ).is_dir ())
490+ assert not (P / "brokenLink" ).is_dir ()
506491
507492
508493def test_is_file (BASE ):
@@ -511,10 +496,10 @@ def test_is_file(BASE):
511496 assert not ((P / "dirA" ).is_file ())
512497 assert not ((P / "non-existing" ).is_file ())
513498 assert not ((P / "fileA" / "bah" ).is_file ())
514- if not symlink_skip_reason :
515- assert ((P / "linkA" ).is_file ())
516- assert not ((P / "linkB" ).is_file ())
517- assert not ((P / "brokenLink" ).is_file ())
499+
500+ assert ((P / "linkA" ).is_file ())
501+ assert not ((P / "linkB" ).is_file ())
502+ assert not ((P / "brokenLink" ).is_file ())
518503
519504
520505@only_posix
@@ -536,10 +521,10 @@ def test_is_symlink(BASE):
536521 assert not ((P / "dirA" ).is_symlink ())
537522 assert not ((P / "non-existing" ).is_symlink ())
538523 assert not ((P / "fileA" / "bah" ).is_symlink ())
539- if not symlink_skip_reason :
540- assert ((P / "linkA" ).is_symlink ())
541- assert ((P / "linkB" ).is_symlink ())
542- assert ((P / "brokenLink" ).is_symlink ())
524+
525+ assert ((P / "linkA" ).is_symlink ())
526+ assert ((P / "linkB" ).is_symlink ())
527+ assert ((P / "brokenLink" ).is_symlink ())
543528
544529
545530def test_is_fifo_false (BASE ):
0 commit comments