FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GH-110109: Adjust `test_pathlib_abc` imports to ease backporting by barneygale · Pull Request #113411 · python/cpython · GitHub

/ cpython Public
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
25 changes: 13 additions & 12 deletions Lib/test/test_pathlib/test_pathlib_abc.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
import io
import os
import errno
import pathlib
import posixpath
import stat
import unittest

from pathlib._abc import UnsupportedOperation, PurePathBase, PathBase
import posixpath

from test.support import set_recursion_limit
from test.support.os_helper import TESTFN


class UnsupportedOperationTest(unittest.TestCase):
def test_is_notimplemented(self):
self.assertTrue(issubclass(pathlib.UnsupportedOperation, NotImplementedError))
self.assertTrue(isinstance(pathlib.UnsupportedOperation(), NotImplementedError))
self.assertTrue(issubclass(UnsupportedOperation, NotImplementedError))
self.assertTrue(isinstance(UnsupportedOperation(), NotImplementedError))


#
Expand All @@ -23,7 +24,7 @@ def test_is_notimplemented(self):


class PurePathBaseTest(unittest.TestCase):
cls = pathlib._abc.PurePathBase
cls = PurePathBase

def test_magic_methods(self):
P = self.cls
Expand All @@ -42,7 +43,7 @@ def test_pathmod(self):
self.assertIs(self.cls.pathmod, posixpath)


class DummyPurePath(pathlib._abc.PurePathBase):
class DummyPurePath(PurePathBase):
def __eq__(self, other):
if not isinstance(other, DummyPurePath):
return NotImplemented
Expand Down Expand Up @@ -637,12 +638,12 @@ def test_is_relative_to_common(self):
#

class PathBaseTest(PurePathBaseTest):
cls = pathlib._abc.PathBase
cls = PathBase

def test_unsupported_operation(self):
P = self.cls
p = self.cls()
e = pathlib.UnsupportedOperation
e = UnsupportedOperation
self.assertRaises(e, p.stat)
self.assertRaises(e, p.lstat)
self.assertRaises(e, p.exists)
Expand Down Expand Up @@ -684,7 +685,7 @@ def test_unsupported_operation(self):
self.assertRaises(e, p.as_uri)

def test_as_uri_common(self):
e = pathlib.UnsupportedOperation
e = UnsupportedOperation
self.assertRaises(e, self.cls().as_uri)

def test_fspath_common(self):
Expand All @@ -709,7 +710,7 @@ def close(self):
super().close()


class DummyPath(pathlib._abc.PathBase):
class DummyPath(PathBase):
"""
Simple implementation of PathBase that keeps files and directories in
memory.
Expand Down Expand Up @@ -1325,7 +1326,7 @@ def test_readlink(self):
def test_readlink_unsupported(self):
P = self.cls(self.base)
p = P / 'fileA'
with self.assertRaises(pathlib.UnsupportedOperation):
with self.assertRaises(UnsupportedOperation):
q.readlink(p)

def _check_resolve(self, p, expected, strict=True):
Expand Down Expand Up @@ -1648,7 +1649,7 @@ def _check_complex_symlinks(self, link0_target):
# Resolve relative paths.
try:
self.cls().absolute()
except pathlib.UnsupportedOperation:
except UnsupportedOperation:
return
old_path = os.getcwd()
os.chdir(self.base)
Expand Down

Back | FazBrowse Home | New Git URL