diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-03-02 09:53:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-02 09:53:51 (GMT) |
commit | b21d155f57d284aecf9092a9bd24258293965c2f (patch) | |
tree | 3bf7797282fa3d3fc48e668214ae5f5c6bce1dff /Lib/test/test_posixpath.py | |
parent | bf63e8d55fd2853df3bb99d66de7f428107aadb3 (diff) | |
download | cpython-b21d155f57d284aecf9092a9bd24258293965c2f.zip cpython-b21d155f57d284aecf9092a9bd24258293965c2f.tar.gz cpython-b21d155f57d284aecf9092a9bd24258293965c2f.tar.bz2 |
bpo-32964: Reuse a testing implementation of the path protocol in tests. (#5930)
Diffstat (limited to 'Lib/test/test_posixpath.py')
-rw-r--r-- | Lib/test/test_posixpath.py | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py index 8a1e33b..96b267c 100644 --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -4,6 +4,7 @@ import unittest import warnings from posixpath import realpath, abspath, dirname, basename from test import support, test_genericpath +from test.support import FakePath try: import posix @@ -600,18 +601,9 @@ class PathLikeTests(unittest.TestCase): path = posixpath - 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) with open(self.file_name, 'xb', 0) as file: file.write(b"test_posixpath.PathLikeTests") @@ -626,7 +618,7 @@ class PathLikeTests(unittest.TestCase): self.assertPathEqual(self.path.isabs) def test_path_join(self): - self.assertEqual(self.path.join('a', self.PathLike('b'), 'c'), + self.assertEqual(self.path.join('a', FakePath('b'), 'c'), self.path.join('a', 'b', 'c')) def test_path_split(self): |