| 1 |
import pytest |
| 2 |
import signal |
| 3 |
|
| 4 |
from billiard.util import set_pdeathsig, get_pdeathsig |
| 5 |
|
| 6 |
from billiard.compat import _winapi |
| 7 |
from t import skip |
| 8 |
|
| 9 |
|
| 10 |
@skip.unless_win32() |
| 11 |
class test_win32_module: |
| 12 |
|
| 13 |
@pytest.mark.parametrize('name', [ |
| 14 |
'NULL', |
| 15 |
'ERROR_ALREADY_EXISTS', |
| 16 |
'ERROR_PIPE_BUSY', |
| 17 |
'ERROR_PIPE_CONNECTED', |
| 18 |
'ERROR_SEM_TIMEOUT', |
| 19 |
'ERROR_MORE_DATA', |
| 20 |
'ERROR_BROKEN_PIPE', |
| 21 |
'ERROR_IO_PENDING', |
| 22 |
'ERROR_NETNAME_DELETED', |
| 23 |
'GENERIC_READ', |
| 24 |
'GENERIC_WRITE', |
| 25 |
'DUPLICATE_SAME_ACCESS', |
| 26 |
'DUPLICATE_CLOSE_SOURCE', |
| 27 |
'INFINITE', |
| 28 |
'NMPWAIT_WAIT_FOREVER', |
| 29 |
'OPEN_EXISTING', |
| 30 |
'PIPE_ACCESS_DUPLEX', |
| 31 |
'PIPE_ACCESS_INBOUND', |
| 32 |
'PIPE_READMODE_MESSAGE', |
| 33 |
'PIPE_TYPE_MESSAGE', |
| 34 |
'PIPE_UNLIMITED_INSTANCES', |
| 35 |
'PIPE_WAIT', |
| 36 |
'PROCESS_ALL_ACCESS', |
| 37 |
'PROCESS_DUP_HANDLE', |
| 38 |
'WAIT_OBJECT_0', |
| 39 |
'WAIT_ABANDONED_0', |
| 40 |
'WAIT_TIMEOUT', |
| 41 |
'FILE_FLAG_FIRST_PIPE_INSTANCE', |
| 42 |
'FILE_FLAG_OVERLAPPED', |
| 43 |
]) |
| 44 |
def test_constants(self, name): |
| 45 |
assert getattr(_winapi, name) is not None |
| 46 |
|
| 47 |
@pytest.mark.parametrize('name', [ |
| 48 |
'Overlapped', |
| 49 |
'CloseHandle', |
| 50 |
'GetLastError', |
| 51 |
'OpenProcess', |
| 52 |
'ExitProcess', |
| 53 |
'ConnectNamedPipe', |
| 54 |
'CreateFile', |
| 55 |
'WriteFile', |
| 56 |
'ReadFile', |
| 57 |
'CreateNamedPipe', |
| 58 |
'SetNamedPipeHandleState', |
| 59 |
'WaitNamedPipe', |
| 60 |
'PeekNamedPipe', |
| 61 |
'WaitForMultipleObjects', |
| 62 |
'WaitForSingleObject', |
| 63 |
'GetCurrentProcess', |
| 64 |
'GetExitCodeProcess', |
| 65 |
'TerminateProcess', |
| 66 |
'DuplicateHandle', |
| 67 |
'CreatePipe', |
| 68 |
]) |
| 69 |
def test_functions(self, name): |
| 70 |
assert getattr(_winapi, name) |
| 71 |
|
| 72 |
def test_set_pdeathsig(self): |
| 73 |
with pytest.raises(OSError): |
| 74 |
set_pdeathsig(signal.SIGTERM) |
| 75 |
|
| 76 |
def test_get_pdeathsig(self): |
| 77 |
with pytest.raises(OSError): |
| 78 |
get_pdeathsig() |