Skip to content

fix: make pytest suite hermetic against local dev-machine state#647

Merged
ElliotSlusky merged 2 commits into
open-jarvis:mainfrom
cesschneider:fix/pytest-failures
Jul 17, 2026
Merged

fix: make pytest suite hermetic against local dev-machine state#647
ElliotSlusky merged 2 commits into
open-jarvis:mainfrom
cesschneider:fix/pytest-failures

Conversation

@cesschneider

@cesschneider cesschneider commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Running uv run pytest tests/ -v on a fresh dev machine (after building the mandatory openjarvis_rust extension) left 13 failures/6 errors that don't reproduce in CI, because CI's environment happens to sidestep two hermeticity gaps in the test suite:

  • CLI update-check nag pollutes captured output. check_for_updates() writes its "new version available" banner to stderr, which Click's CliRunner merges into result.output. It already no-ops under CI=true, but a plain local run (network access + a version-check cache showing a newer release) gets the banner appended after JSON/CSV output, breaking json.loads(result.output) in doctor --json, config show --json, ask --json, telemetry export --json/--csv, etc.
  • test_dense.py's Ollama skip-guard only checks TCP connectivity, not whether the nomic-embed-text embed model is actually pulled. On a machine that runs Ollama for chat models but hasn't pulled that specific embed model, the retrieval-quality tests error out instead of skipping as the module docstring promises ("skipped if the server is unreachable").

Changes

  • tests/conftest.py: new autouse fixture sets OPENJARVIS_NO_UPDATE_CHECK=1 for the whole suite, so the update-check nag never fires locally either.
  • tests/tools/storage/test_dense.py: _ollama_up() now hits /api/tags and checks that nomic-embed-text is present, instead of a bare socket.create_connection port check.

No production code changed — this is purely test-isolation. Confirmed green with the suite's canonical CI invocation:

uv run pytest tests/ -n auto -q --tb=short -m "not live and not cloud and not hub"
# 7201 passed, 56 skipped, 0 failed

Related issue

Unit tests failing

Test plan

  • uv run pytest tests/ -n auto -q -m "not live and not cloud and not hub" — 7201 passed, 56 skipped
  • uv run ruff check tests/conftest.py tests/tools/storage/test_dense.py — clean
  • uv run ruff format --check tests/conftest.py tests/tools/storage/test_dense.py — clean
  • Verified tests/cli/test_version_check.py (which manages OPENJARVIS_NO_UPDATE_CHECK itself) still passes unaffected, since its local _clean_env fixture overrides the new global default.

Two sources of non-deterministic local failures in `pytest tests/`:

- The CLI's PyPI update-check nag writes its banner to stderr, which
  Click's CliRunner merges into result.output. It self-disables under
  CI=true, but a dev running tests locally with network access and a
  stale version-check cache gets the banner appended to JSON/CSV CLI
  output, breaking every test that parses it. Disable it unconditionally
  for the whole suite via an autouse fixture in tests/conftest.py.

- tests/tools/storage/test_dense.py's Ollama skip-guard only checked TCP
  connectivity, not whether the `nomic-embed-text` embed model was
  pulled. On a machine running Ollama for chat models but without that
  specific model, the tests errored instead of skipping as documented.
  _ollama_up() now checks /api/tags for the model.

Also required rebuilding the openjarvis_rust PyO3 extension (missing —
most core modules hard-require it) and re-syncing the dev/server extras
that a bare `uv sync`/`uv run` had silently dropped relative to the
desktop-native dependency group.
@cesschneider
cesschneider force-pushed the fix/pytest-failures branch from c2dc63d to 18a8f53 Compare July 17, 2026 04:36
…d endpoint into backend

- OLLAMA_HOST is documented as a full URL (http://host:11434); the probe
  built http://<url>:<port>/api/tags from it. Normalize full-URL,
  host:port, and bare-host forms into one base URL.
- DenseMemory() built its embedder with the hard-coded localhost
  default, so a remote OLLAMA_HOST could pass the probe and then have
  every test hit the wrong server. Ollama-backed tests now construct
  the backend against the probed endpoint.
- Drop OLLAMA_PORT (test-only knob the runtime never honored).
- Unit tests for the probe: server down, model missing, tagged model,
  configured URL.

@ElliotSlusky ElliotSlusky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Both fixes verified: the update-check suppression is correct (the dedicated version-check tests manage the env var themselves and all 33 pass), and the model-aware Ollama probe reproduces correctly on a machine running Ollama without nomic-embed-text (13 passed / 9 skipped instead of errors). Pushed a follow-up: the probe now normalizes OLLAMA_HOST's documented full-URL form (it previously built http://:/api/tags), and the Ollama-backed tests construct DenseMemory against the same probed endpoint instead of the embedder's hard-coded localhost default, with unit tests for the probe itself.

@ElliotSlusky
ElliotSlusky merged commit b6dba93 into open-jarvis:main Jul 17, 2026
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.

2 participants