mirror of
https://github.com/python/cpython.git
synced 2025-07-16 07:45:20 +00:00
GH-112855: Slightly improve tests for pathlib.PurePath
pickling (#113243)
Add a few more simple test cases, like non-anchored paths. Remove misplaced and indirect test that pickling doesn't change the `stat()` value.
This commit is contained in:
parent
4a3d2419bb
commit
ff5e131df5
2 changed files with 10 additions and 16 deletions
|
@ -60,14 +60,16 @@ class PurePathTest(test_pathlib_abc.DummyPurePathTest):
|
|||
|
||||
def test_pickling_common(self):
|
||||
P = self.cls
|
||||
p = P('/a/b')
|
||||
for proto in range(0, pickle.HIGHEST_PROTOCOL + 1):
|
||||
dumped = pickle.dumps(p, proto)
|
||||
pp = pickle.loads(dumped)
|
||||
self.assertIs(pp.__class__, p.__class__)
|
||||
self.assertEqual(pp, p)
|
||||
self.assertEqual(hash(pp), hash(p))
|
||||
self.assertEqual(str(pp), str(p))
|
||||
for pathstr in ('a', 'a/', 'a/b', 'a/b/c', '/', '/a/b', '/a/b/c', 'a/b/c/'):
|
||||
with self.subTest(pathstr=pathstr):
|
||||
p = P(pathstr)
|
||||
for proto in range(0, pickle.HIGHEST_PROTOCOL + 1):
|
||||
dumped = pickle.dumps(p, proto)
|
||||
pp = pickle.loads(dumped)
|
||||
self.assertIs(pp.__class__, p.__class__)
|
||||
self.assertEqual(pp, p)
|
||||
self.assertEqual(hash(pp), hash(p))
|
||||
self.assertEqual(str(pp), str(p))
|
||||
|
||||
def test_repr_common(self):
|
||||
for pathstr in ('a', 'a/b', 'a/b/c', '/', '/a/b', '/a/b/c'):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue