Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mock_win32process.py 1.3KB

1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright (c) Twisted Matrix Laboratories.
  2. # See LICENSE for details.
  3. """
  4. This is a mock win32process module.
  5. The purpose of this module is mock process creation for the PID test.
  6. CreateProcess(...) will spawn a process, and always return a PID of 42.
  7. """
  8. import win32process # type: ignore[import]
  9. GetExitCodeProcess = win32process.GetExitCodeProcess
  10. STARTUPINFO = win32process.STARTUPINFO
  11. STARTF_USESTDHANDLES = win32process.STARTF_USESTDHANDLES
  12. def CreateProcess(
  13. appName,
  14. cmdline,
  15. procSecurity,
  16. threadSecurity,
  17. inheritHandles,
  18. newEnvironment,
  19. env,
  20. workingDir,
  21. startupInfo,
  22. ):
  23. """
  24. This function mocks the generated pid aspect of the win32.CreateProcess
  25. function.
  26. - the true win32process.CreateProcess is called
  27. - return values are harvested in a tuple.
  28. - all return values from createProcess are passed back to the calling
  29. function except for the pid, the returned pid is hardcoded to 42
  30. """
  31. hProcess, hThread, dwPid, dwTid = win32process.CreateProcess(
  32. appName,
  33. cmdline,
  34. procSecurity,
  35. threadSecurity,
  36. inheritHandles,
  37. newEnvironment,
  38. env,
  39. workingDir,
  40. startupInfo,
  41. )
  42. dwPid = 42
  43. return (hProcess, hThread, dwPid, dwTid)