@@ -433,6 +433,40 @@ def test_sync_tree_links():
433
433
assert f .read () == "content"
434
434
435
435
436
+ def test_sync_tree_top_source_is_link ():
437
+ """Check handling of source top is a link."""
438
+ e3 .fs .mkdir ("a" )
439
+ with open ("a/content" , "w" ) as f :
440
+ f .write ("content" )
441
+
442
+ try :
443
+ # Symlinks are supported on Windows, but the user must have sufficient
444
+ # permissions.
445
+ os .symlink (
446
+ os .path .join (os .getcwd (), "a" ),
447
+ os .path .join (os .getcwd (), "b" ),
448
+ target_is_directory = True ,
449
+ )
450
+ except Exception as e :
451
+ if sys .platform == "win32" :
452
+ pytest .skip ("Insufficient permissions to create symbolic links on Windows" )
453
+ else :
454
+ raise e
455
+
456
+ # Sync tree in "c", source top is "b", which is a symlink to "a".
457
+ e3 .fs .mkdir ("c" )
458
+ e3 .fs .sync_tree (
459
+ os .path .join (os .getcwd (), "b" ),
460
+ os .path .join (os .getcwd (), "c" , "a" ),
461
+ preserve_timestamps = False ,
462
+ )
463
+
464
+ # Make sure "c/a" is not a symlink
465
+ assert not os .path .islink (os .path .join (os .getcwd (), "c" , "a" ))
466
+ with open ("c/a/content" ) as f :
467
+ assert f .read () == "content"
468
+
469
+
436
470
def test_sync_tree_does_not_exist ():
437
471
"""Check error message when sync_tree source does not exist."""
438
472
with pytest .raises (e3 .fs .FSError ) as err :
0 commit comments