Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(13563)

Delta Between Two Patch Sets: Lib/test/test_pathlib.py

Issue 19921: Path.mkdir(0, True) always fails
Left Patch Set: Created 5 years, 9 months ago
Right Patch Set: Created 5 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/pathlib.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 import collections 1 import collections
2 import io 2 import io
3 import os 3 import os
4 import errno 4 import errno
5 import pathlib 5 import pathlib
6 import pickle 6 import pickle
7 import shutil 7 import shutil
8 import socket 8 import socket
9 import stat 9 import stat
10 import sys 10 import sys
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 with self.assertRaises(OSError) as cm: 1487 with self.assertRaises(OSError) as cm:
1488 p.mkdir() 1488 p.mkdir()
1489 self.assertEqual(cm.exception.errno, errno.ENOENT) 1489 self.assertEqual(cm.exception.errno, errno.ENOENT)
1490 p.mkdir(parents=True) 1490 p.mkdir(parents=True)
1491 self.assertTrue(p.exists()) 1491 self.assertTrue(p.exists())
1492 self.assertTrue(p.is_dir()) 1492 self.assertTrue(p.is_dir())
1493 with self.assertRaises(OSError) as cm: 1493 with self.assertRaises(OSError) as cm:
1494 p.mkdir(parents=True) 1494 p.mkdir(parents=True)
1495 self.assertEqual(cm.exception.errno, errno.EEXIST) 1495 self.assertEqual(cm.exception.errno, errno.EEXIST)
1496 # test `mode` arg 1496 # test `mode` arg
1497 shutil.rmtree(join('newdirB')) 1497 mode = stat.S_IMODE(p.stat().st_mode) # default mode
AntoinePitrou 2013/12/07 22:21:59 Rather than calling rmtree() here, better create a
1498 p.mkdir(0o444, parents=True) 1498 p = self.cls(BASE, 'newdirD', 'newdirE')
1499 p.mkdir(0o555, parents=True)
1499 self.assertTrue(p.exists()) 1500 self.assertTrue(p.exists())
1500 self.assertTrue(p.is_dir()) 1501 self.assertTrue(p.is_dir())
1501 self.assertEqual(stat.S_IMODE(p.stat().st_mode), 0o444) 1502 if os.name != 'nt':
AntoinePitrou 2013/12/07 22:21:59 Under Windows, a directory will be either 0o555 or
1502 self.assertEqual(stat.S_IMODE(p.parent.stat().st_mode), 0o775) 1503 self.assertEqual(stat.S_IMODE(p.stat().st_mode), 0o555 & mode)
AntoinePitrou 2013/12/07 22:21:59 Er... 0o775 is your personal umask, right?
1504 self.assertEqual(stat.S_IMODE(p.parent.stat().st_mode), mode)
1503 1505
1504 @with_symlinks 1506 @with_symlinks
1505 def test_symlink_to(self): 1507 def test_symlink_to(self):
1506 P = self.cls(BASE) 1508 P = self.cls(BASE)
1507 target = P / 'fileA' 1509 target = P / 'fileA'
1508 # Symlinking a path target 1510 # Symlinking a path target
1509 link = P / 'dirA' / 'linkAA' 1511 link = P / 'dirA' / 'linkAA'
1510 link.symlink_to(target) 1512 link.symlink_to(target)
1511 self.assertEqual(link.stat(), target.stat()) 1513 self.assertEqual(link.stat(), target.stat())
1512 self.assertNotEqual(link.lstat(), target.stat()) 1514 self.assertNotEqual(link.lstat(), target.stat())
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 self.assertEqual(set(p.glob("FILEa")), { P(BASE, "fileA") }) 1728 self.assertEqual(set(p.glob("FILEa")), { P(BASE, "fileA") })
1727 1729
1728 def test_rglob(self): 1730 def test_rglob(self):
1729 P = self.cls 1731 P = self.cls
1730 p = P(BASE, "dirC") 1732 p = P(BASE, "dirC")
1731 self.assertEqual(set(p.rglob("FILEd")), { P(BASE, "dirC/dirD/fileD") }) 1733 self.assertEqual(set(p.rglob("FILEd")), { P(BASE, "dirC/dirD/fileD") })
1732 1734
1733 1735
1734 if __name__ == "__main__": 1736 if __name__ == "__main__":
1735 unittest.main() 1737 unittest.main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+