@@ -4158,6 +4158,8 @@ def check_entry(self, entry, name, is_dir, is_file, is_symlink):
41584158 self .assertEqual (entry .is_file (follow_symlinks = False ),
41594159 stat .S_ISREG (entry_lstat .st_mode ))
41604160
4161+ self .assertEqual (entry .is_junction (), os .path .isjunction (entry .path ))
4162+
41614163 self .assert_stat_equal (entry .stat (),
41624164 entry_stat ,
41634165 os .name == 'nt' and not is_symlink )
@@ -4206,6 +4208,21 @@ def test_attributes(self):
42064208 entry = entries ['symlink_file.txt' ]
42074209 self .check_entry (entry , 'symlink_file.txt' , False , True , True )
42084210
4211+ @unittest .skipIf (sys .platform != 'win32' , "Can only test junctions with creation on win32." )
4212+ def test_attributes_junctions (self ):
4213+ dirname = os .path .join (self .path , "tgtdir" )
4214+ os .mkdir (dirname )
4215+
4216+ import _winapi
4217+ try :
4218+ _winapi .CreateJunction (dirname , os .path .join (self .path , "srcjunc" ))
4219+ except OSError :
4220+ raise unittest .SkipTest ('creating the test junction failed' )
4221+
4222+ entries = self .get_entries (['srcjunc' , 'tgtdir' ])
4223+ self .assertEqual (entries ['srcjunc' ].is_junction (), True )
4224+ self .assertEqual (entries ['tgtdir' ].is_junction (), False )
4225+
42094226 def get_entry (self , name ):
42104227 path = self .bytes_path if isinstance (name , bytes ) else self .path
42114228 entries = list (os .scandir (path ))
0 commit comments