()
| 134 | |
| 135 | |
| 136 | async def test_WaitForSingleObject() -> None: |
| 137 | # This does a series of test for setting/closing the handle before |
| 138 | # initiating the wait. |
| 139 | |
| 140 | # Test already set |
| 141 | handle = kernel32.CreateEventA(ffi.NULL, True, False, ffi.NULL) |
| 142 | kernel32.SetEvent(handle) |
| 143 | await WaitForSingleObject(handle) # should return at once |
| 144 | kernel32.CloseHandle(handle) |
| 145 | print("test_WaitForSingleObject already set OK") |
| 146 | |
| 147 | # Test already set, as int |
| 148 | handle = kernel32.CreateEventA(ffi.NULL, True, False, ffi.NULL) |
| 149 | handle_int = int(ffi.cast("intptr_t", handle)) |
| 150 | kernel32.SetEvent(handle) |
| 151 | await WaitForSingleObject(handle_int) # should return at once |
| 152 | kernel32.CloseHandle(handle) |
| 153 | print("test_WaitForSingleObject already set OK") |
| 154 | |
| 155 | # Test already closed |
| 156 | handle = kernel32.CreateEventA(ffi.NULL, True, False, ffi.NULL) |
| 157 | kernel32.CloseHandle(handle) |
| 158 | with pytest.raises(OSError, match=r"^\[WinError 6\] The handle is invalid$"): |
| 159 | await WaitForSingleObject(handle) # should return at once |
| 160 | print("test_WaitForSingleObject already closed OK") |
| 161 | |
| 162 | # Not a handle |
| 163 | with pytest.raises(TypeError): |
| 164 | await WaitForSingleObject("not a handle") # type: ignore[arg-type] # Wrong type |
| 165 | # with pytest.raises(OSError): |
| 166 | # await WaitForSingleObject(99) # If you're unlucky, it actually IS a handle :( |
| 167 | print("test_WaitForSingleObject not a handle OK") |
| 168 | |
| 169 | |
| 170 | @slow |
nothing calls this directly
no test coverage detected
searching dependent graphs…