mirror of
https://github.com/python/cpython.git
synced 2025-10-07 07:31:46 +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
|
@ -9,6 +9,7 @@ import unittest
|
|||
import warnings
|
||||
from test import support
|
||||
from test.support.script_helper import assert_python_ok
|
||||
from test.support import FakePath
|
||||
|
||||
|
||||
def create_file(filename, data=b'foo'):
|
||||
|
@ -493,18 +494,9 @@ class CommonTest(GenericTest):
|
|||
|
||||
class PathLikeTests(unittest.TestCase):
|
||||
|
||||
class PathLike:
|
||||
def __init__(self, path=''):
|
||||
self.path = path
|
||||
def __fspath__(self):
|
||||
if isinstance(self.path, BaseException):
|
||||
raise self.path
|
||||
else:
|
||||
return self.path
|
||||
|
||||
def setUp(self):
|
||||
self.file_name = support.TESTFN.lower()
|
||||
self.file_path = self.PathLike(support.TESTFN)
|
||||
self.file_path = FakePath(support.TESTFN)
|
||||
self.addCleanup(support.unlink, self.file_name)
|
||||
create_file(self.file_name, b"test_genericpath.PathLikeTests")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue