[3.12] gh-119064: Use os_helper.FakePath instead of pathlib.Path in tests (GH-119065) (GH-119088)

(cherry picked from commit 0152dc4ff5)
This commit is contained in:
Serhiy Storchaka 2024-05-16 11:04:37 +03:00 committed by GitHub
parent ed395f5c0e
commit 33a9f0ce65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 116 additions and 128 deletions

View file

@ -6,7 +6,6 @@ import io
import multiprocessing
from multiprocessing.util import _cleanup_tests as multiprocessing_cleanup_tests
import os
import pathlib
import signal
import socket
import stat
@ -304,20 +303,20 @@ class SelectorEventLoopUnixSocketTests(test_utils.TestCase):
self.loop.run_until_complete(srv.wait_closed())
@socket_helper.skip_unless_bind_unix_socket
def test_create_unix_server_pathlib(self):
def test_create_unix_server_pathlike(self):
with test_utils.unix_socket_path() as path:
path = pathlib.Path(path)
path = os_helper.FakePath(path)
srv_coro = self.loop.create_unix_server(lambda: None, path)
srv = self.loop.run_until_complete(srv_coro)
srv.close()
self.loop.run_until_complete(srv.wait_closed())
def test_create_unix_connection_pathlib(self):
def test_create_unix_connection_pathlike(self):
with test_utils.unix_socket_path() as path:
path = pathlib.Path(path)
path = os_helper.FakePath(path)
coro = self.loop.create_unix_connection(lambda: None, path)
with self.assertRaises(FileNotFoundError):
# If pathlib.Path wasn't supported, the exception would be
# If path-like object weren't supported, the exception would be
# different.
self.loop.run_until_complete(coro)