From 43db8082bdcc430776e85fe37da9a025d75ed660 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 28 Jul 2020 12:54:02 +0200 Subject: [PATCH] test/jsoncomm: check accept with no clients Ensure that if `accept` is called on a normal listener socket, i.e. the socket is in non-blocking mode, `None` is returned. --- test/mod/test_util_jsoncomm.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/mod/test_util_jsoncomm.py b/test/mod/test_util_jsoncomm.py index 72a192b0..acb6d30b 100644 --- a/test/mod/test_util_jsoncomm.py +++ b/test/mod/test_util_jsoncomm.py @@ -165,3 +165,14 @@ class TestUtilJsonComm(unittest.TestCase): msg = self.client.recv() assert msg[0] == {} + + def test_accept_timeout(self): + # + # Test calling `accept` without any connection being ready to be + # established will not throw any exceptions but return `None` + address = pathlib.Path(self.dir.name, "noblock") + listener = jsoncomm.Socket.new_server(address) + listener.listen() + + conn = listener.accept() + self.assertIsNone(conn)