Skip to content

fix: repair node health test import#4873

Open
Asti1982 wants to merge 1 commit into
Scottcjn:mainfrom
Asti1982:codex/fix-node-health-test-import
Open

fix: repair node health test import#4873
Asti1982 wants to merge 1 commit into
Scottcjn:mainfrom
Asti1982:codex/fix-node-health-test-import

Conversation

@Asti1982
Copy link
Copy Markdown

Summary

  • fix the node-health CLI test import path so the suite works from the repository root
  • add the missing SPDX header to the touched test file

Root cause

tools/node-health-cli/tests/test_node_health.py inserted the tests directory into sys.path, but node_health.py lives one directory above it. Running the suite from the repo root therefore failed during collection with ModuleNotFoundError: No module named 'node_health'.

Verification

  • python -m pytest tools\\node-health-cli\\tests\\test_node_health.py -q -> 24 passed
  • python -m py_compile tools\\node-health-cli\\node_health.py tools\\node-health-cli\\tests\\test_node_health.py -> passed
  • python tools\\bcos_spdx_check.py --base-ref origin/main -> BCOS SPDX check: OK
  • git diff --check -- tools\\node-health-cli\\tests\\test_node_health.py -> passed

@github-actions
Copy link
Copy Markdown
Contributor

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Your PR has a BCOS-L1 or BCOS-L2 label
  • New code files include an SPDX license header
  • You've tested your changes against the live node

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!

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/XS PR: 1-10 lines labels May 12, 2026
Copy link
Copy Markdown

@saim256 saim256 left a comment

Choose a reason for hiding this comment

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

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 passed
  • python -m py_compile tools\node-health-cli\node_health.py tools\node-health-cli\tests\test_node_health.py -> passed
  • git diff --check origin/main...HEAD -- tools/node-health-cli/tests/test_node_health.py -> passed
  • python tools\bcos_spdx_check.py --base-ref origin/main -> BCOS SPDX check: OK

Copy link
Copy Markdown
Contributor

@508704820 508704820 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: 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

  1. Pathlib migration: Path.resolve().parents[1] is more robust than os.path
  2. Correct parent: parents[1] correctly navigates up from tests/ to the tool directory
  3. SPDX header: Added MIT license identifier
  4. Clean: Removes os import, adds pathlib

Verdict: Approve

Clean import path fix with modern pathlib usage.

Copy link
Copy Markdown

@loganoe loganoe left a comment

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

Great contribution! LGTM.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

Great contribution! LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/XS PR: 1-10 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants