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:
Barney Gale 2023-12-22 17:49:09 +00:00 committed by GitHub
parent 4a3d2419bb
commit ff5e131df5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 16 deletions

View file

@ -60,7 +60,9 @@ class PurePathTest(test_pathlib_abc.DummyPurePathTest):
def test_pickling_common(self):
P = self.cls
p = P('/a/b')
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)

View file

@ -3,7 +3,6 @@ import io
import os
import errno
import pathlib
import pickle
import posixpath
import stat
import unittest
@ -1644,13 +1643,6 @@ class DummyPathTest(DummyPurePathTest):
self.assertIs((P / 'fileA\udfff').is_char_device(), False)
self.assertIs((P / 'fileA\x00').is_char_device(), False)
def test_pickling_common(self):
p = self.cls(self.base, 'fileA')
for proto in range(0, pickle.HIGHEST_PROTOCOL + 1):
dumped = pickle.dumps(p, proto)
pp = pickle.loads(dumped)
self.assertEqual(pp.stat(), p.stat())
def test_parts_interning(self):
P = self.cls
p = P('/usr/bin/foo')