Skip to content

Fix pytest ModuleNotFoundError: No module named 'src'#5

Draft
Copilot wants to merge 9 commits intomainfrom
copilot/fix-test-collection-error
Draft

Fix pytest ModuleNotFoundError: No module named 'src'#5
Copilot wants to merge 9 commits intomainfrom
copilot/fix-test-collection-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

Tests in tests/test_hodgkin_huxley_dynamics.py fail to collect because src is not on sys.path when pytest runs — despite the project root containing the src/ package directory.

Change

Added [tool.pytest.ini_options] to pyproject.toml with pythonpath = ["."] to instruct pytest to add the project root to sys.path:

[tool.pytest.ini_options]
pythonpath = ["."]

This makes from src.signal_processing.hodgkin_huxley_model import HodgkinHuxleyModel resolvable without modifying test files or the package structure.

Copilot AI changed the title [WIP] Fix test collection error in Hodgkin-Huxley dynamics Fix pytest ModuleNotFoundError: No module named 'src' Apr 9, 2026
Copilot AI requested a review from DaScient April 9, 2026 18:54
@DaScient DaScient requested a review from Copilot April 9, 2026 19:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds pytest configuration to ensure the repository root is added to sys.path during test runs, resolving ModuleNotFoundError: No module named 'src' during collection in environments that don’t install the project as a package.

Changes:

  • Add [tool.pytest.ini_options] to pyproject.toml.
  • Configure pythonpath = ["."] so src.* imports resolve under pytest.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

where = ["src"]

[tool.pytest.ini_options]
pythonpath = ["."]
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

pythonpath = ["."] makes import src.* work when running tests from the repo checkout, but it also cements src as an importable top-level package. This conflicts with the existing setuptools packages.find where = ["src"] (src-layout), where installed code would typically be imported as signal_processing... / dascient_suite... (without the src. prefix). Consider aligning the import strategy by either (a) switching pytest pythonpath to ["src"] and updating tests to import the real packages, or (b) adjusting the packaging config to actually ship a top-level src package if that’s the intended public import path.

Suggested change
pythonpath = ["."]
pythonpath = ["src"]

Copilot uses AI. Check for mistakes.
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.

3 participants