fix: repair node health test import#4873
Conversation
|
Welcome to RustChain! Thanks for your first pull request. Before we review, please make sure:
Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150) A maintainer will review your PR soon. Thanks for contributing! |
saim256
left a comment
There was a problem hiding this comment.
Approved after focused validation. The test now inserts the node-health CLI package directory rather than the tests directory, so node_health.py resolves when the suite is run from the repository root, and the touched test file now has the required SPDX header.
Checks run locally on the PR branch:
python -m pytest tools\node-health-cli\tests\test_node_health.py -q-> 24 passedpython -m py_compile tools\node-health-cli\node_health.py tools\node-health-cli\tests\test_node_health.py-> passedgit diff --check origin/main...HEAD -- tools/node-health-cli/tests/test_node_health.py-> passedpython tools\bcos_spdx_check.py --base-ref origin/main-> BCOS SPDX check: OK
508704820
left a comment
There was a problem hiding this comment.
Code Review: Repair Node Health Test Import
Summary
Fixes test import path: replaces os.path.dirname(os.path.abspath(file)) with Path(file).resolve().parents[1] for more reliable module resolution. Adds SPDX license header.
What Works Well
- Pathlib migration: Path.resolve().parents[1] is more robust than os.path
- Correct parent: parents[1] correctly navigates up from tests/ to the tool directory
- SPDX header: Added MIT license identifier
- Clean: Removes os import, adds pathlib
Verdict: Approve
Clean import path fix with modern pathlib usage.
loganoe
left a comment
There was a problem hiding this comment.
Reviewed the import-path repair for the node health CLI tests. Moving the test sys.path entry to the tool root makes the node_health module importable from the test directory without changing runtime code. Verified with: PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest -q tools/node-health-cli/tests/test_node_health.py (24 passed).
jaxint
left a comment
There was a problem hiding this comment.
Great contribution! LGTM.
jaxint
left a comment
There was a problem hiding this comment.
Great contribution! LGTM.
Summary
Root cause
tools/node-health-cli/tests/test_node_health.pyinserted thetestsdirectory intosys.path, butnode_health.pylives one directory above it. Running the suite from the repo root therefore failed during collection withModuleNotFoundError: No module named 'node_health'.Verification
python -m pytest tools\\node-health-cli\\tests\\test_node_health.py -q-> 24 passedpython -m py_compile tools\\node-health-cli\\node_health.py tools\\node-health-cli\\tests\\test_node_health.py-> passedpython tools\\bcos_spdx_check.py --base-ref origin/main-> BCOS SPDX check: OKgit diff --check -- tools\\node-health-cli\\tests\\test_node_health.py-> passed