mirror of
https://github.com/python/cpython.git
synced 2025-10-06 07:02:33 +00:00
bpo-32964: Reuse a testing implementation of the path protocol in tests. (GH-5930)
(cherry picked from commit b21d155f57
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
0e06be836c
commit
a13b65422a
11 changed files with 70 additions and 103 deletions
|
@ -11,7 +11,7 @@ import unittest
|
|||
from unittest import mock
|
||||
|
||||
from test import support
|
||||
TESTFN = support.TESTFN
|
||||
from test.support import TESTFN, FakePath
|
||||
|
||||
try:
|
||||
import grp, pwd
|
||||
|
@ -191,18 +191,15 @@ class _BasePurePathTest(object):
|
|||
P = self.cls
|
||||
p = P('a')
|
||||
self.assertIsInstance(p, P)
|
||||
class PathLike:
|
||||
def __fspath__(self):
|
||||
return "a/b/c"
|
||||
P('a', 'b', 'c')
|
||||
P('/a', 'b', 'c')
|
||||
P('a/b/c')
|
||||
P('/a/b/c')
|
||||
P(PathLike())
|
||||
P(FakePath("a/b/c"))
|
||||
self.assertEqual(P(P('a')), P('a'))
|
||||
self.assertEqual(P(P('a'), 'b'), P('a/b'))
|
||||
self.assertEqual(P(P('a'), P('b')), P('a/b'))
|
||||
self.assertEqual(P(P('a'), P('b'), P('c')), P(PathLike()))
|
||||
self.assertEqual(P(P('a'), P('b'), P('c')), P(FakePath("a/b/c")))
|
||||
|
||||
def _check_str_subclass(self, *args):
|
||||
# Issue #21127: it should be possible to construct a PurePath object
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue