Skip to content

Refactor: drop dead sys.path hacks in tests/ut/py/#603

Merged
ChaoWao merged 1 commit intohw-native-sys:mainfrom
ChaoWao:cleanup-test-sys-path-hacks
Apr 20, 2026
Merged

Refactor: drop dead sys.path hacks in tests/ut/py/#603
ChaoWao merged 1 commit intohw-native-sys:mainfrom
ChaoWao:cleanup-test-sys-path-hacks

Conversation

@ChaoWao
Copy link
Copy Markdown
Collaborator

@ChaoWao ChaoWao commented Apr 20, 2026

Summary

Three test files under `tests/ut/py` carried their own `sys.path.insert` blocks that duplicated what the sibling `tests/ut/py/conftest.py` already does — and, under any `pip install` mode, they're redundant with site-packages anyway.

What's dropped

File What it did Why it's dead
`tests/ut/py/test_chip_worker.py` Inserted `python/` to find `_task_interface` Already on `sys.path` via `tests/ut/py/conftest.py`; installed at wheel root under `pip install`.
`tests/ut/py/test_task_interface.py` Same hack, same reason Ditto.
`tests/ut/py/test_worker/test_platform_comm.py` Inserted project root + `python/` Inherited from the PR #571 stash (standalone-execution pattern); PR #597 (L1b) always relies on conftest / installed package.

Intentionally NOT touched

  • `tests/ut/py/conftest.py` — upstream PR Refactor: relocate build_runtimes.py to simpler_setup #600 (`1e6660f`) just refreshed this file's `sys.path` list when `build_runtimes.py` moved. That's a maintained design choice for the no-install workflow ("importable without installing the package"), so I let it stand. The per-test dupes are the only load-bearing-free leftovers.
  • `tests/conftest.py` — still uses `sys.path.insert(tools/)` to import `test_catalog`. `tools/` isn't a Python package at all; cleaning that up requires moving `test_catalog` into `simpler_setup/` or similar. Separate PR.

Verification

`pytest tests/ut/py --ignore=tests/ut/py/test_hostsub_fork_shm.py` before and after: 170 passed, 6 skipped in both cases.

Net diff

`3 files changed, 1 insertion(+), 28 deletions(-)`

Test plan

  • `pytest tests/ut/py --ignore=tests/ut/py/test_hostsub_fork_shm.py` — 170 pass, 6 skip on macOS 3.14
  • CI `ut (ubuntu-latest, 3.10)` / `ut (macos-latest, 3.10)` green
  • CI `ut-a2a3` (hardware) still green

🤖 Generated with Claude Code

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes manual sys.path modifications and related imports from several test files, including test_chip_worker.py, test_task_interface.py, and test_platform_comm.py. It also cleans up ruff: noqa: E402 directives that are no longer necessary. I have no feedback to provide.

docs/python-packaging.md rule 2 bans sys.path.insert outside
examples/scripts/build_runtimes.py.  Three test files under tests/ut/py
carried their own sys.path inserts that duplicated what
tests/ut/py/conftest.py already does (and, under any install mode,
they are covered by site-packages anyway):

- tests/ut/py/test_chip_worker.py: inserted python/ to find
  _task_interface.  Already on sys.path via the sibling conftest and
  installed at the wheel root under pip install.
- tests/ut/py/test_task_interface.py: same hack, same reason.
- tests/ut/py/test_worker/test_platform_comm.py: inserted project root
  and python/.  Inherited from the stash of PR hw-native-sys#571 which was written
  for standalone execution; PR hw-native-sys#597 (L1b) always relies on the
  installed package or conftest-managed sys.path.

tests/ut/py/conftest.py is deliberately left alone — upstream PR hw-native-sys#600
just refreshed its sys.path list for the no-install workflow
(\"importable without installing the package\"), so the conftest-level
hack is a maintained design choice; the per-test duplicates were
simply redundant.

Ran `pytest tests/ut/py --ignore=tests/ut/py/test_hostsub_fork_shm.py`
before and after the removal: 170 passed, 6 skipped in both cases.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ChaoWao ChaoWao force-pushed the cleanup-test-sys-path-hacks branch from 3b51c6e to 50f72c8 Compare April 20, 2026 09:16
@ChaoWao ChaoWao merged commit a3cf871 into hw-native-sys:main Apr 20, 2026
14 checks passed
@ChaoWao ChaoWao deleted the cleanup-test-sys-path-hacks branch April 20, 2026 09:35
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