@@ -50,22 +50,8 @@ def _umask_0():
50
50
os .umask (old_mask )
51
51
52
52
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 ()
66
53
only_nt = pytest .mark .skipif (condition = os .name != "nt" , reason = "test requires a Windows-compatible system" )
67
54
only_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
69
55
70
56
71
57
@pytest .fixture ()
@@ -99,14 +85,14 @@ def dirlink(src, dest):
99
85
with open (join ("dirC" , "dirD" , "fileD" ), "wb" ) as f :
100
86
f .write (b"this is file D\n " )
101
87
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" ))
110
96
111
97
yield tmp_pathplus
112
98
@@ -468,7 +454,6 @@ def my_mkdir(path, mode=0o777):
468
454
assert (p .exists ())
469
455
470
456
471
- @with_symlinks
472
457
def test_symlink_to (BASE ):
473
458
P = PathPlus (BASE )
474
459
target = P / "fileA"
@@ -499,10 +484,10 @@ def test_is_dir(BASE):
499
484
assert not ((P / "fileA" ).is_dir ())
500
485
assert not ((P / "non-existing" ).is_dir ())
501
486
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 ()
506
491
507
492
508
493
def test_is_file (BASE ):
@@ -511,10 +496,10 @@ def test_is_file(BASE):
511
496
assert not ((P / "dirA" ).is_file ())
512
497
assert not ((P / "non-existing" ).is_file ())
513
498
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 ())
518
503
519
504
520
505
@only_posix
@@ -536,10 +521,10 @@ def test_is_symlink(BASE):
536
521
assert not ((P / "dirA" ).is_symlink ())
537
522
assert not ((P / "non-existing" ).is_symlink ())
538
523
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 ())
543
528
544
529
545
530
def test_is_fifo_false (BASE ):
0 commit comments