Skip to content

fix: resolve 15 test failures on Windows platform#300

Open
rubuslab wants to merge 1 commit into
HKUDS:mainfrom
rubuslab:fix/windows-test-failed
Open

fix: resolve 15 test failures on Windows platform#300
rubuslab wants to merge 1 commit into
HKUDS:mainfrom
rubuslab:fix/windows-test-failed

Conversation

@rubuslab

@rubuslab rubuslab commented Jun 10, 2026

Copy link
Copy Markdown

Fixes test suite failures when running on Windows (win32) due to
platform-specific behaviors not being properly handled.

Source code fixes:

  • src/openharness/swarm/team_lifecycle.py: Use Path.replace() instead of Path.rename() for atomic file writes, as rename() raises FileExistsError on Windows when the target already exists
  • src/openharness/autopilot/service.py: Use posix=False for shlex.split() on Windows to handle backslash paths correctly
  • src/openharness/ui/input.py: Lazily initialize PromptSession to avoid NoConsoleScreenBufferError when no Windows console is attached
  • pyproject.toml: Add tzdata dependency for timezone support on Windows (where system timezone data is not available to Python's zoneinfo)

Test fixes:

  • tests/test_ohmo/test_gateway.py: Mock Windows-specific process management (wmic + taskkill) instead of POSIX-only (ps + os.kill); replace deprecated datetime.utcnow() with datetime.now(UTC)
  • tests/test_swarm/test_lockfile.py: Skip POSIX-only fcntl test on Windows
  • tests/test_swarm/test_registry.py: Use explicit InProcessBackend registration instead of monkeypatch to avoid module cache invalidation from test_imports.py
  • tests/test_tools/test_bash_tool.py: Use monkeypatch.setitem on function globals to correctly mock imported create_shell_subprocess
  • tests/test_utils/test_shell.py: Mock get_platform() to ensure consistent shell binary expectations across platforms

Summary

  • Fix 15 test failures and resolve lint issues when running the test suite on Windows (win32).
  • Bug fixed in tests.

Validation

  • uv run ruff check src tests scripts
  • uv run pytest -q
  • cd frontend/terminal && npx tsc --noEmit (if frontend touched)

Notes

  • Related issue:
  • Follow-up work:

  Fixes test suite failures when running on Windows (win32) due to
  platform-specific behaviors not being properly handled.

  Source code fixes:
  - src/openharness/swarm/team_lifecycle.py: Use Path.replace() instead of
    Path.rename() for atomic file writes, as rename() raises FileExistsError
    on Windows when the target already exists
  - src/openharness/autopilot/service.py: Use posix=False for shlex.split()
    on Windows to handle backslash paths correctly
  - src/openharness/ui/input.py: Lazily initialize PromptSession to avoid
    NoConsoleScreenBufferError when no Windows console is attached
  - pyproject.toml: Add tzdata dependency for timezone support on Windows
    (where system timezone data is not available to Python's zoneinfo)

  Test fixes:
  - tests/test_ohmo/test_gateway.py: Mock Windows-specific process
    management (wmic + taskkill) instead of POSIX-only (ps + os.kill);
    replace deprecated datetime.utcnow() with datetime.now(UTC)
  - tests/test_swarm/test_lockfile.py: Skip POSIX-only fcntl test on Windows
  - tests/test_swarm/test_registry.py: Use explicit InProcessBackend
    registration instead of monkeypatch to avoid module cache invalidation
    from test_imports.py
  - tests/test_tools/test_bash_tool.py: Use monkeypatch.setitem on
    function globals to correctly mock imported create_shell_subprocess
  - tests/test_utils/test_shell.py: Mock get_platform() to ensure
    consistent shell binary expectations across platforms
@rubuslab

Copy link
Copy Markdown
Author
image Before the fix, run test cmd "uv run pytest -q" on Windows.The test results show 15 failures.

@rubuslab

Copy link
Copy Markdown
Author
image After fix, all tests passed on Windows.

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