MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_broken_symlink

Method test_broken_symlink

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

Source from the content-addressed store, hash-verified

5272 self.assertRaises(FileNotFoundError, entry.stat, follow_symlinks=False)
5273
5274 def test_broken_symlink(self):
5275 if not os_helper.can_symlink():
5276 return self.skipTest('cannot create symbolic link')
5277
5278 filename = self.create_file("file.txt")
5279 os.symlink(filename,
5280 os.path.join(self.path, "symlink.txt"))
5281 entries = self.get_entries(['file.txt', 'symlink.txt'])
5282 entry = entries['symlink.txt']
5283 os.unlink(filename)
5284
5285 self.assertGreater(entry.inode(), 0)
5286 self.assertFalse(entry.is_dir())
5287 self.assertFalse(entry.is_file()) # broken symlink returns False
5288 self.assertFalse(entry.is_dir(follow_symlinks=False))
5289 self.assertFalse(entry.is_file(follow_symlinks=False))
5290 self.assertTrue(entry.is_symlink())
5291 self.assertRaises(FileNotFoundError, entry.stat)
5292 # don't fail
5293 entry.stat(follow_symlinks=False)
5294
5295 def test_bytes(self):
5296 self.create_file("file.txt")

Callers

nothing calls this directly

Calls 14

create_fileMethod · 0.95
get_entriesMethod · 0.95
skipTestMethod · 0.80
assertGreaterMethod · 0.80
inodeMethod · 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

Tested by

no test coverage detected