summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ntpath.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-03-03 12:19:29 (GMT)
committerGitHub <noreply@github.com>2018-03-03 12:19:29 (GMT)
commitfbdd075c64a5229dfa26632cf1b2cf2361dc5003 (patch)
treea959f2fc206302c629b217ca811f305b7f5060be /Lib/test/test_ntpath.py
parent10fb1bf7766e7eb9500d328ddd1035e3f823fb57 (diff)
downloadcpython-fbdd075c64a5229dfa26632cf1b2cf2361dc5003.zip
cpython-fbdd075c64a5229dfa26632cf1b2cf2361dc5003.tar.gz
cpython-fbdd075c64a5229dfa26632cf1b2cf2361dc5003.tar.bz2
[3.6] bpo-32964: Reuse a testing implementation of the path protocol in tests. (GH-5930). (GH-5958)
(cherry picked from commit b21d155f57d284aecf9092a9bd24258293965c2f) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test/test_ntpath.py')
-rw-r--r--Lib/test/test_ntpath.py15
1 files changed, 3 insertions, 12 deletions
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py
index 90edb6d..4076184 100644
--- a/Lib/test/test_ntpath.py
+++ b/Lib/test/test_ntpath.py
@@ -3,7 +3,7 @@ import os
import sys
import unittest
import warnings
-from test.support import TestFailed
+from test.support import TestFailed, FakePath
from test import support, test_genericpath
from tempfile import TemporaryFile
@@ -456,18 +456,9 @@ class PathLikeTests(unittest.TestCase):
path = ntpath
- 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_ntpath.PathLikeTests")
@@ -482,7 +473,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):