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

Method test_mkdir_parents

Lib/test/test_pathlib/test_pathlib.py:2371–2394  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2369 self.assertEqual(cm.exception.errno, errno.EEXIST)
2370
2371 def test_mkdir_parents(self):
2372 # Creating a chain of directories.
2373 p = self.cls(self.base, 'newdirB', 'newdirC')
2374 self.assertFalse(p.exists())
2375 with self.assertRaises(OSError) as cm:
2376 p.mkdir()
2377 self.assertEqual(cm.exception.errno, errno.ENOENT)
2378 p.mkdir(parents=True)
2379 self.assertTrue(p.exists())
2380 self.assertTrue(p.is_dir())
2381 with self.assertRaises(OSError) as cm:
2382 p.mkdir(parents=True)
2383 self.assertEqual(cm.exception.errno, errno.EEXIST)
2384 # Test `mode` arg.
2385 mode = stat.S_IMODE(p.stat().st_mode) # Default mode.
2386 p = self.cls(self.base, 'newdirD', 'newdirE')
2387 p.mkdir(0o555, parents=True)
2388 self.assertTrue(p.exists())
2389 self.assertTrue(p.is_dir())
2390 if os.name != 'nt':
2391 # The directory's permissions follow the mode argument.
2392 self.assertEqual(stat.S_IMODE(p.stat().st_mode), 0o7555 & mode)
2393 # The parent's permissions follow the default process settings.
2394 self.assertEqual(stat.S_IMODE(p.parent.stat().st_mode), mode)
2395
2396 def test_mkdir_exist_ok(self):
2397 p = self.cls(self.base, 'dirB')

Callers

nothing calls this directly

Calls 9

assertFalseMethod · 0.80
assertTrueMethod · 0.80
clsMethod · 0.45
existsMethod · 0.45
assertRaisesMethod · 0.45
mkdirMethod · 0.45
assertEqualMethod · 0.45
is_dirMethod · 0.45
statMethod · 0.45

Tested by

no test coverage detected