mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-118507 : Refactor ntpath native functions (gh-119381)
This refactoring will make future backports easier without changing behaviours, apart from correcting a bug when passing a pipe to `ntpath.isfile`.
This commit is contained in:
parent
8c96850161
commit
874a4f7d08
5 changed files with 372 additions and 416 deletions
|
@ -976,6 +976,27 @@ class TestNtpath(NtpathTestCase):
|
|||
raise unittest.SkipTest('SystemDrive is not defined or malformed')
|
||||
self.assertFalse(os.path.isfile('\\\\.\\' + drive))
|
||||
|
||||
@unittest.skipUnless(hasattr(os, 'pipe'), "need os.pipe()")
|
||||
def test_isfile_anonymous_pipe(self):
|
||||
pr, pw = os.pipe()
|
||||
try:
|
||||
self.assertFalse(ntpath.isfile(pr))
|
||||
finally:
|
||||
os.close(pr)
|
||||
os.close(pw)
|
||||
|
||||
@unittest.skipIf(sys.platform != 'win32', "windows only")
|
||||
def test_isfile_named_pipe(self):
|
||||
import _winapi
|
||||
named_pipe = f'//./PIPE/python_isfile_test_{os.getpid()}'
|
||||
h = _winapi.CreateNamedPipe(named_pipe,
|
||||
_winapi.PIPE_ACCESS_INBOUND,
|
||||
0, 1, 0, 0, 0, 0)
|
||||
try:
|
||||
self.assertFalse(ntpath.isfile(named_pipe))
|
||||
finally:
|
||||
_winapi.CloseHandle(h)
|
||||
|
||||
@unittest.skipIf(sys.platform != 'win32', "windows only")
|
||||
def test_con_device(self):
|
||||
self.assertFalse(os.path.isfile(r"\\.\CON"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue