tests(hipfile): Add unit tests for hipFile python module - #8725
Conversation
❌ PR Check — Action Required
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🚫 Please fix the failed policies before requesting reviews. The following policy checks failed:
The |
There was a problem hiding this comment.
Pull request overview
Adds a hermetic pytest unit-test suite for the high-level hipfile Python API (mocking the Cython extension via sys.modules) and wires these tests into the existing hipfile-python-bindings GitHub Actions workflow.
Changes:
- Introduces hermetic unit tests covering
Driver,FileHandle,Buffer,properties,enums, andHipFileException. - Adds shared pytest fixtures (
conftest.py), local pytest discovery config (pytest.ini), and test-suite documentation (README.md). - Updates CI workflow to install
pytestand execute the new unit tests inside the container.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/hipfile/python/tests/conftest.py | Injects a fake hipfile._hipfile module and provides shared fixtures for hermetic unit tests. |
| projects/hipfile/python/tests/test_buffer.py | Unit tests for hipfile.buffer.Buffer registration, error paths, and context manager behavior. |
| projects/hipfile/python/tests/test_driver.py | Unit tests for hipfile.driver.Driver open/close, error handling, and context manager ordering. |
| projects/hipfile/python/tests/test_enums.py | Unit tests for enum int-like behavior (currently focused on OpError). |
| projects/hipfile/python/tests/test_error.py | Unit tests for HipFileException stored codes and string formatting. |
| projects/hipfile/python/tests/test_file.py | Unit tests for FileHandle handle_type guards, open/close lifecycle, and read/write error contracts. |
| projects/hipfile/python/tests/test_properties.py | Unit tests for get_version and driver_get_properties success/error behavior. |
| projects/hipfile/python/tests/README.md | Documents test hermeticity approach, running instructions, and file coverage map. |
| projects/hipfile/python/tests/pytest.ini | Local pytest configuration for discovery under python/tests. |
| .github/workflows/hipfile-python-bindings.yml | Installs pytest and runs the new Python unit tests in CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
These unit tests specifically target the higher-level Python API, and do not test anything lower. These tests can be run without building the Cython bindings.
e7ee553 to
4e61158
Compare
(#8725) ## Motivation Adds unit tests to cover our high-level Python API ## Technical Details These tests are only to test the logic implemented by the high-level Python APIs added here. The Cython layer and C library are not tested here. To keep these tests hermetic, the Cython layer is faked. ## Issue Tracking JIRA ID: AIHIPFILE-164 ## Test Plan New unit tests added ## Test Result See hipFile CI ## Submission Checklist - [ ] Look over the contributing guidelines at https://github.com/ROCm/rocm-systems/blob/develop/CONTRIBUTING.md. [rocm-systems] ROCm/rocm-systems#8725 (commit 0e4167d)
## Motivation The hipFile Python test suite has been broken at collection since the async I/O bindings (#7386): that PR added `AsyncIOHandle` and the async/stream callables to the extension and imported them in `file.py`, but never updated the fake in `conftest.py`. Every test importing `hipfile` errored during collection. Missed because CI wasn't re-run after the unit tests (#8725) landed. ## Technical Details Add the missing async names to the fake extension in `conftest.py`: a `_FakeAsyncIOHandle` stand-in plus success-shaped `hipFileReadAsync` / `hipFileWriteAsync` / `hipFileStreamRegister` / `hipFileStreamDeregister` / `supports_async`. Tests-only change. ## Issue Tracking JIRA ID: AIHIPFILE-171 ## Test Plan - Run the hipFile Python binding suite: `pytest projects/hipfile/python/tests/`. - Lint the changed file: `black --check` and `pylint` on `conftest.py`. ## Test Result - `42 passed` (previously: 5 collection errors, suite could not run). - `black --check`: file left unchanged. `pylint`: rated 10.00/10. ## Submission Checklist - [x] Look over the contributing guidelines at https://github.com/ROCm/rocm-systems/blob/develop/CONTRIBUTING.md.
Motivation
Adds unit tests to cover our high-level Python API
Technical Details
These tests are only to test the logic implemented by the high-level Python APIs added here. The Cython layer and C library are not tested here. To keep these tests hermetic, the Cython layer is faked.
Issue Tracking
JIRA ID: AIHIPFILE-164
Test Plan
New unit tests added
Test Result
See hipFile CI
Submission Checklist