Skip to content

tests: fake os.killpg/signal.SIGKILL for Windows in remote-job test - #140

Open
KNambiarDJsc wants to merge 1 commit into
huggingface:mainfrom
KNambiarDJsc:fix/remote-job-test-windows-attrs
Open

KNambiarDJsc wants to merge 1 commit into
huggingface:mainfrom
KNambiarDJsc:fix/remote-job-test-windows-attrs

Conversation

@KNambiarDJsc

Copy link
Copy Markdown
Contributor

Summary

Continuing the Windows-portability triage from #130. test_timeout_terminates_process_group_and_its_owned_containers mocks both Popen and killpg to exercise execute()'s timeout/cleanup state machine without touching a real OS — but monkeypatch.setattr's default raising=True requires the target attribute to already exist, and neither os.killpg nor signal.SIGKILL exists on Windows at all. The test failed before its fake was even installed:

AttributeError: <module 'os' (frozen)> has no attribute 'killpg'

and, after patching that, a second one:

AttributeError: module 'signal' has no attribute 'SIGKILL'. Did you mean: 'SIGILL'?

execute() only ever runs for real inside a Linux remote worker (REPO2RLENV_REMOTE_WORKER=1; killpg needs a POSIX process group), so this doesn't touch production code — same reasoning as the os.chown guards in #136, just with raising=False letting the existing fakes install cleanly and the test verify the real cleanup logic from any host OS.

Test plan

  • uv run pytest tests/test_remote_job.py -q — 3 passed (was 1 failed before this change)
  • uv run ruff check / ruff format --check on the touched file
  • Full suite still collects and runs cleanly with this change (no new failures introduced; test_remote_job.py no longer appears in the Windows failure set)

test_timeout_terminates_process_group_and_its_owned_containers mocks
both Popen and killpg to exercise execute()'s timeout/cleanup state
machine without touching a real OS. Neither os.killpg nor
signal.SIGKILL exists on Windows, so monkeypatch.setattr's default
raising=True failed before the fake was even installed.

execute() only ever runs for real inside a Linux remote worker
(REPO2RLENV_REMOTE_WORKER=1, killpg needs a POSIX process group), so
this doesn't change production code — it lets the existing coverage
of that logic run from a Windows host too, same shape as the
os.chown guards in huggingface#136.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant