MCPcopy Index your code
hub / github.com/python/cpython / test_islink

Method test_islink

Lib/test/test_posixpath.py:193–209  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

191 self.assertEqual(posixpath.dirname(b"//foo//bar"), b"//foo")
192
193 def test_islink(self):
194 self.assertIs(posixpath.islink(TESTFN + "1"), False)
195 self.assertIs(posixpath.lexists(TESTFN + "2"), False)
196
197 self.addCleanup(os_helper.unlink, TESTFN + "1")
198 with open(TESTFN + "1", "wb") as f:
199 f.write(b"foo")
200 self.assertIs(posixpath.islink(TESTFN + "1"), False)
201
202 if os_helper.can_symlink():
203 self.addCleanup(os_helper.unlink, TESTFN + "2")
204 os.symlink(TESTFN + "1", TESTFN + "2")
205 self.assertIs(posixpath.islink(TESTFN + "2"), True)
206 os.remove(TESTFN + "1")
207 self.assertIs(posixpath.islink(TESTFN + "2"), True)
208 self.assertIs(posixpath.exists(TESTFN + "2"), False)
209 self.assertIs(posixpath.lexists(TESTFN + "2"), True)
210
211 def test_islink_invalid_paths(self):
212 self.assertIs(posixpath.islink(TESTFN + "\udfff"), False)

Callers

nothing calls this directly

Calls 8

islinkMethod · 0.80
addCleanupMethod · 0.80
openFunction · 0.50
assertIsMethod · 0.45
lexistsMethod · 0.45
writeMethod · 0.45
removeMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected