MCPcopy
hub / github.com/psycopg/psycopg / test_wait_w

Function test_wait_w

tests/test_waiting.py:222–237  ·  view source on GitHub ↗
(waitfn, event, request)

Source from the content-addressed store, hash-verified

220@pytest.mark.parametrize("event", ["W", "RW"])
221@pytest.mark.parametrize("waitfn", waitfns)
222def test_wait_w(waitfn, event, request):
223 # Test that wait functions handle waiting and returning state correctly
224 waitfn = getattr(waiting, waitfn)
225 wait = getattr(waiting.Wait, event)
226
227 rs, ws = socket.socketpair() # the w socket is already ready for writing
228 rs.setblocking(False)
229 ws.setblocking(False)
230 with rs, ws:
231 t0 = time.time()
232 r = waitfn(tgen(wait), ws.fileno(), 0.5)
233 dt = time.time() - t0
234 # Check timing and received waiting state
235 assert r == waiting.Ready.W
236 if check_timing(request):
237 assert dt < 0.1
238
239
240@pytest.mark.parametrize("waitfn", waitfns)

Callers

nothing calls this directly

Calls 3

filenoMethod · 0.80
tgenFunction · 0.70
check_timingFunction · 0.70

Tested by

no test coverage detected