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.
This commit is contained in:
Christian Kellner 2020-07-28 12:54:02 +02:00 committed by Tom Gundersen
parent 8388a64ffa
commit 43db8082bd

View file

@ -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)