mirror of
https://github.com/python/cpython.git
synced 2025-08-27 20:25:18 +00:00
bpo-32066: Support pathlib.Path in create_unix_connection; sock arg should be optional (#4447)
This commit is contained in:
parent
895862aa01
commit
423fd362f8
5 changed files with 31 additions and 8 deletions
|
@ -251,7 +251,6 @@ class SelectorEventLoopUnixSocketTests(test_utils.TestCase):
|
|||
srv.close()
|
||||
self.loop.run_until_complete(srv.wait_closed())
|
||||
|
||||
@unittest.skipUnless(hasattr(os, 'fspath'), 'no os.fspath')
|
||||
def test_create_unix_server_pathlib(self):
|
||||
with test_utils.unix_socket_path() as path:
|
||||
path = pathlib.Path(path)
|
||||
|
@ -260,6 +259,15 @@ class SelectorEventLoopUnixSocketTests(test_utils.TestCase):
|
|||
srv.close()
|
||||
self.loop.run_until_complete(srv.wait_closed())
|
||||
|
||||
def test_create_unix_connection_pathlib(self):
|
||||
with test_utils.unix_socket_path() as path:
|
||||
path = pathlib.Path(path)
|
||||
coro = self.loop.create_unix_connection(lambda: None, path)
|
||||
with self.assertRaises(FileNotFoundError):
|
||||
# If pathlib.Path wasn't supported, the exception would be
|
||||
# different.
|
||||
self.loop.run_until_complete(coro)
|
||||
|
||||
def test_create_unix_server_existing_path_nonsock(self):
|
||||
with tempfile.NamedTemporaryFile() as file:
|
||||
coro = self.loop.create_unix_server(lambda: None, file.name)
|
||||
|
@ -319,7 +327,7 @@ class SelectorEventLoopUnixSocketTests(test_utils.TestCase):
|
|||
def test_create_unix_connection_path_inetsock(self):
|
||||
sock = socket.socket()
|
||||
with sock:
|
||||
coro = self.loop.create_unix_connection(lambda: None, path=None,
|
||||
coro = self.loop.create_unix_connection(lambda: None,
|
||||
sock=sock)
|
||||
with self.assertRaisesRegex(ValueError,
|
||||
'A UNIX Domain Stream.*was expected'):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue