`self.server.recv()` should probably be `self.server.recv_maybe()` instead followed by `self.assertTrue(dg is not None, msg="No datagram received.")`.

The same for lines: 161 and 250