diff options
author | Yury Selivanov <yury@magic.io> | 2016-11-09 20:47:00 (GMT) |
---|---|---|
committer | Yury Selivanov <yury@magic.io> | 2016-11-09 20:47:00 (GMT) |
commit | a1a8b7d3d7f628aec31be364c77cbb3e21cdbc0b (patch) | |
tree | f1c1fa5ae61d965d131a437904bd1712c7a6f017 /Lib/test/test_asyncio/test_unix_events.py | |
parent | d2fd3599abeed393ccdf4ee5cf1c7b346ba4a022 (diff) | |
download | cpython-a1a8b7d3d7f628aec31be364c77cbb3e21cdbc0b.zip cpython-a1a8b7d3d7f628aec31be364c77cbb3e21cdbc0b.tar.gz cpython-a1a8b7d3d7f628aec31be364c77cbb3e21cdbc0b.tar.bz2 |
Issue #28652: Make loop methods reject socket kinds they do not support.
Diffstat (limited to 'Lib/test/test_asyncio/test_unix_events.py')
-rw-r--r-- | Lib/test/test_asyncio/test_unix_events.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py index 83a035e..89c6eed 100644 --- a/Lib/test/test_asyncio/test_unix_events.py +++ b/Lib/test/test_asyncio/test_unix_events.py @@ -280,6 +280,33 @@ class SelectorEventLoopUnixSocketTests(test_utils.TestCase): 'A UNIX Domain Stream.*was expected'): self.loop.run_until_complete(coro) + def test_create_unix_server_path_dgram(self): + sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) + with sock: + coro = self.loop.create_unix_server(lambda: None, path=None, + sock=sock) + with self.assertRaisesRegex(ValueError, + 'A UNIX Domain Stream.*was expected'): + self.loop.run_until_complete(coro) + + @unittest.skipUnless(hasattr(socket, 'SOCK_NONBLOCK'), + 'no socket.SOCK_NONBLOCK (linux only)') + def test_create_unix_server_path_stream_bittype(self): + sock = socket.socket( + socket.AF_UNIX, socket.SOCK_STREAM | socket.SOCK_NONBLOCK) + with tempfile.NamedTemporaryFile() as file: + fn = file.name + try: + with sock: + sock.bind(fn) + coro = self.loop.create_unix_server(lambda: None, path=None, + sock=sock) + srv = self.loop.run_until_complete(coro) + srv.close() + self.loop.run_until_complete(srv.wait_closed()) + finally: + os.unlink(fn) + def test_create_unix_connection_path_inetsock(self): sock = socket.socket() with sock: |