Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a1326c8
GH-65238: Preserve trailing slash in pathlib
barneygale Nov 24, 2023
df1e115
Fix absolute() on bare DOS drive
barneygale Nov 24, 2023
61be2e3
Simplify diff
barneygale Nov 24, 2023
445364a
Reduce diff
barneygale Nov 24, 2023
6395815
Speed up _make_child_relpath()
barneygale Nov 24, 2023
435be1b
Ignore empty initialiser arguments for backwards compat
barneygale Nov 25, 2023
e577a67
Merge branch 'main' into keep-trailing-slash-wip3
barneygale Nov 25, 2023
d766d06
Simplify implementation
barneygale Dec 1, 2023
12cfb1a
Merge branch 'main' into keep-trailing-slash-wip3
barneygale Dec 2, 2023
2593ddb
Merge branch 'main' into keep-trailing-slash-wip3
barneygale Dec 3, 2023
b275078
Add tests
barneygale Dec 3, 2023
5d87cf4
Docstrings
barneygale Dec 4, 2023
af12c24
Docs
barneygale Dec 4, 2023
cae3774
Ensure has_trailing_sep is boolean
barneygale Dec 4, 2023
d4c87c6
Add tests for new methods/properties
barneygale Dec 4, 2023
1a77c8a
Fix WindowsPath('C:').absolute()
barneygale Dec 4, 2023
120beed
Merge branch 'main' into keep-trailing-slash-wip3
barneygale Dec 4, 2023
df79c49
Don't access `.parts` from `._glob()`
barneygale Dec 7, 2023
0f75804
Fix pickle roundtripping
barneygale Dec 7, 2023
eeb35ff
Undo changes to `parts`
barneygale Dec 7, 2023
153c4af
Merge branch 'main' into keep-trailing-slash-wip3
barneygale Dec 7, 2023
b852339
Simplify `_glob()` slightly
barneygale Dec 7, 2023
2b77a61
Fix possible scoping issue in `_glob()`
barneygale Dec 7, 2023
7b6766f
Formatting
barneygale Dec 8, 2023
f5c2265
Add test cases for preserving slash in absolute() and expanduser()
barneygale Dec 8, 2023
1126117
Add notes to `match()` and `glob()` docs
barneygale Dec 8, 2023
9c9b5ea
Merge branch 'main' into keep-trailing-slash-wip3
barneygale Dec 8, 2023
9539c60
Merge branch 'main' into keep-trailing-slash-wip3
barneygale Dec 11, 2023
14a9635
Merge branch 'main' into keep-trailing-slash-wip3
barneygale Dec 17, 2023
305381b
Undo pickling change
barneygale Dec 17, 2023
dfe7aae
Undo pickling changes.
barneygale Dec 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test cases for preserving slash in absolute() and expanduser()
  • Loading branch information
barneygale committed Dec 8, 2023
commit f5c226577f66c24349d9127c1fb5dbb85bfde0a4
12 changes: 12 additions & 0 deletions Lib/test/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -3039,6 +3039,9 @@ def test_absolute_common(self):
self.assertEqual(str(P('a', '..').absolute()), os.path.join(BASE, 'a', '..'))
self.assertEqual(str(P('..', 'b').absolute()), os.path.join(BASE, '..', 'b'))

# Trailing slash should be preserved
self.assertEqual(str(P('a/').absolute()), os.path.join(BASE, 'a', ''))

def _test_home(self, p):
q = self.cls(os.path.expanduser('~'))
self.assertEqual(p, q)
Expand Down Expand Up @@ -3066,6 +3069,12 @@ def test_expanduser_common(self):
P = self.cls
p = P('~')
self.assertEqual(p.expanduser(), P(os.path.expanduser('~')))
p = P('~/')
self.assertEqual(p.expanduser(), P(os.path.expanduser('~/')))
p = P('~/foo')
self.assertEqual(p.expanduser(), P(os.path.expanduser('~/foo')))
p = P('~/foo/')
self.assertEqual(p.expanduser(), P(os.path.expanduser('~/foo/')))
p = P('foo')
self.assertEqual(p.expanduser(), p)
p = P('/~')
Expand Down Expand Up @@ -3845,10 +3854,12 @@ def test_absolute(self):
# Relative path with root
self.assertEqual(str(P('\\').absolute()), drive + '\\')
self.assertEqual(str(P('\\foo').absolute()), drive + '\\foo')
self.assertEqual(str(P('\\foo\\').absolute()), drive + '\\foo\\')

# Relative path on current drive
self.assertEqual(str(P(drive).absolute()), BASE)
self.assertEqual(str(P(drive + 'foo').absolute()), os.path.join(BASE, 'foo'))
self.assertEqual(str(P(drive + 'foo\\').absolute()), os.path.join(BASE, 'foo\\'))

with os_helper.subst_drive(BASE) as other_drive:
# Set the working directory on the substitute drive
Expand All @@ -3860,6 +3871,7 @@ def test_absolute(self):
# Relative path on another drive
self.assertEqual(str(P(other_drive).absolute()), other_cwd)
self.assertEqual(str(P(other_drive + 'foo').absolute()), other_cwd + '\\foo')
self.assertEqual(str(P(other_drive + 'foo\\').absolute()), other_cwd + '\\foo\\')

def test_glob(self):
P = self.cls
Expand Down