Skip to content

test: point pytest discovery at existing test roots#420

Open
DivyamTalwar wants to merge 1 commit into
morphik-org:mainfrom
DivyamTalwar:test/pytest-discovery-roots
Open

test: point pytest discovery at existing test roots#420
DivyamTalwar wants to merge 1 commit into
morphik-org:mainfrom
DivyamTalwar:test/pytest-discovery-roots

Conversation

@DivyamTalwar

Copy link
Copy Markdown

Summary

Pytest was configured to look for tests under a root-level tests/ directory that does not exist in this repository. That made local collection emit PytestConfigWarning: No files were found in testpaths and then fall back to recursive discovery.

This PR points pytest at the repository's real Python test roots and corrects the SDK pythonpath entry to the actual local SDK package path.

Changes

  • Update pytest.ini testpaths to core/tests and sdks/python/morphik/tests.
  • Update pytest.ini pythonpath from non-existent ../sdks/python to the local SDK package root at sdks/python.
  • Refresh the inline testpaths comment so it reflects the repository layout.

Why this matters

Contributors should not see a misleading pytest configuration warning when collecting tests from the repository root. Keeping pytest discovery and import paths aligned with the actual repo layout makes local test feedback clearer and avoids relying on recursive fallback behavior.

This also removes false configuration noise for maintainers validating branches from the repository root, and it makes root collection use the workspace SDK package instead of depending on whatever SDK package happens to be importable.

Tests

Commands run:

  • .venv/bin/python -m pytest --collect-only -q --ignore=core/tests/unit/test_ingestion_colpali_rendering.py -W error::pytest.PytestConfigWarning — passed; collected 242 tests and reported testpaths: core/tests, sdks/python/morphik/tests.
  • git diff --check origin/main...HEAD — passed.

Known pre-existing issue

I also ran .venv/bin/python -m pytest --collect-only -q to check the root collection behavior end to end. It still fails on the existing ValueError: 'POSTGRES_URI' needed if 'database.provider' is set to 'postgres' collection error from core/tests/unit/test_ingestion_colpali_rendering.py, which is outside this PR's scope. The previous missing-testpaths warning was gone in that run.

Risk

Risk level: low

This is limited to pytest configuration. The intended behavior change is that root-level pytest collection uses the explicit repository test roots instead of a missing path plus recursive fallback.

Issue

No existing issue. This was discovered during repository analysis.

Notes for maintainers

This PR intentionally does not address the existing POSTGRES_URI import-time collection failure. That is separate from pytest discovery configuration.

Follow-up worth considering: the root pytest configuration now explicitly includes both core and SDK tests, matching current recursive discovery behavior. A later PR could clarify marker/default-suite policy for SDK live-server tests if maintainers want a separate offline-only root command.

The repository has Python tests under core/tests and sdks/python/morphik/tests, but pytest.ini pointed testpaths at a missing tests directory and pythonpath at a non-existent SDK path. Pytest therefore warned and fell back to recursive discovery before hitting unrelated collection failures.

Constraint: Keep this to pytest configuration; do not change tests or runtime imports.
Rejected: Hiding the ingestion settings collection failure | that is a separate import-time settings issue already handled by another PR.
Confidence: high
Scope-risk: narrow
Directive: Keep pytest testpaths aligned with real test roots when adding or moving test packages.
Tested: .venv/bin/python -m pytest --collect-only -q --ignore=core/tests/unit/test_ingestion_colpali_rendering.py -W error::pytest.PytestConfigWarning; git diff --check origin/main...HEAD; full collect-only attempted and confirmed no missing-testpaths warning before the existing POSTGRES_URI failure.
Not-tested: A fully passing root collect-only run remains blocked by the existing POSTGRES_URI import-time failure in core/tests/unit/test_ingestion_colpali_rendering.py.
@DivyamTalwar
DivyamTalwar marked this pull request as ready for review July 3, 2026 20:57
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.

1 participant