Skip to content

test helper import relies on pytest path injection; fragile outside pytest #256

@coderabbitai

Description

@coderabbitai

Summary

The test helper assert_no_toolchain_override defined in .github/actions/rust-build-release/tests/rust_build_release_test_helpers.py is imported by test modules (e.g. test_manifest_path.py) using a bare module import:

from rust_build_release_test_helpers import assert_no_toolchain_override

The tests directory currently has no __init__.py, so it is not a Python package. This bare import works only because pytest injects the directory into sys.path. Importing the test module directly outside pytest fails with:

ModuleNotFoundError: No module named 'rust_build_release_test_helpers'

Changing the import to a relative form (from .rust_build_release_test_helpers import ...) would also fail under the current layout because there is no package context.

Recommended fix

Either:

  • Add an __init__.py to .github/actions/rust-build-release/tests/ to make it a proper Python package and switch to relative imports (from .rust_build_release_test_helpers import ...), or
  • Move the helper into a module that is importable consistently by all test runners (e.g. via conftest.py or a properly installed package).

Context

Identified during review of PR #255 (#255) and verified against the current state of the branch; not addressed in that PR.

Reported by @leynos.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions