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:
Miss Islington (bot) 2018-03-02 02:17:51 -08:00 committed by GitHub
parent 0e06be836c
commit a13b65422a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 70 additions and 103 deletions

View file

@ -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