MCPcopy Create free account
hub / github.com/python/cpython / test_broken_symlink

Method test_broken_symlink

Lib/test/test_os/test_os.py:4998–5017  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4996 self.assertRaises(FileNotFoundError, entry.stat, follow_symlinks=False)
4997
4998 def test_broken_symlink(self):
4999 if not os_helper.can_symlink():
5000 return self.skipTest('cannot create symbolic link')
5001
5002 filename = self.create_file("file.txt")
5003 os.symlink(filename,
5004 os.path.join(self.path, "symlink.txt"))
5005 entries = self.get_entries(['file.txt', 'symlink.txt'])
5006 entry = entries['symlink.txt']
5007 os.unlink(filename)
5008
5009 self.assertGreater(entry.inode(), 0)
5010 self.assertFalse(entry.is_dir())
5011 self.assertFalse(entry.is_file()) # broken symlink returns False
5012 self.assertFalse(entry.is_dir(follow_symlinks=False))
5013 self.assertFalse(entry.is_file(follow_symlinks=False))
5014 self.assertTrue(entry.is_symlink())
5015 self.assertRaises(FileNotFoundError, entry.stat)
5016 # don't fail
5017 entry.stat(follow_symlinks=False)
5018
5019 def test_bytes(self):
5020 self.create_file("file.txt")

Callers

nothing calls this directly

Calls 13

create_fileMethod · 0.95
get_entriesMethod · 0.95
skipTestMethod · 0.80
assertGreaterMethod · 0.80
assertFalseMethod · 0.80
assertTrueMethod · 0.80
joinMethod · 0.45
unlinkMethod · 0.45
is_dirMethod · 0.45
is_fileMethod · 0.45
is_symlinkMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected