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

Method test_rmtree_fails_on_junctions_onerror

Lib/test/test_shutil.py:256–273  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

254
255 @unittest.skipUnless(_winapi, 'only relevant on Windows')
256 def test_rmtree_fails_on_junctions_onerror(self):
257 tmp = self.mkdtemp()
258 dir_ = os.path.join(tmp, 'dir')
259 os.mkdir(dir_)
260 link = os.path.join(tmp, 'link')
261 _winapi.CreateJunction(dir_, link)
262 self.addCleanup(os_helper.unlink, link)
263 self.assertRaises(OSError, shutil.rmtree, link)
264 self.assertTrue(os.path.exists(dir_))
265 self.assertTrue(os.path.lexists(link))
266 errors = []
267 def onerror(*args):
268 errors.append(args)
269 shutil.rmtree(link, onerror=onerror)
270 self.assertEqual(len(errors), 1)
271 self.assertIs(errors[0][0], os.path.islink)
272 self.assertEqual(errors[0][1], link)
273 self.assertIsInstance(errors[0][2][1], OSError)
274
275 @unittest.skipUnless(_winapi, 'only relevant on Windows')
276 def test_rmtree_fails_on_junctions_onexc(self):

Callers

nothing calls this directly

Calls 11

mkdtempMethod · 0.80
addCleanupMethod · 0.80
assertTrueMethod · 0.80
assertIsInstanceMethod · 0.80
joinMethod · 0.45
mkdirMethod · 0.45
assertRaisesMethod · 0.45
existsMethod · 0.45
lexistsMethod · 0.45
assertEqualMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected