[Bug] The persist step-order tests leave a stub `FullTextSearch` on `repowise.core.persistence`

Open
#6,343 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@DEMONCODEX is already working on this.

Since Nov 26, 2026.

  • #6353 by @DEMONCODEX — open
  • #6453 by @Papito084 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
testing

Research direction

Read tests/unit/_persist_step_recorders.py around lines 156–158 and the lazy export in persistence/__init__.py around lines 181–190. Run the two-file pytest command in the issue to reproduce the failures, then check that it passes after fixing the patch order. The issue’s done criteria also require a comment naming the lazy export; keep the step-order assertions unchanged.

Written by the indexing model from the issue text.

Description

bug good first issue

Summary

Run the incremental step-order tests and then the update reliability tests in one process, and two tests fail with '_FTS' object has no attribute 'index'. Each file passes alone, and CI sharding hides it.

tests/unit/_persist_step_recorders.py:156-158

fts = rec.fts_class()
rec.monkeypatch.setattr(search, "FullTextSearch", fts)
rec.monkeypatch.setattr(persistence, "FullTextSearch", fts)

Mechanism

  • repowise.core.persistence exports FullTextSearch lazily. Its __getattr__ imports .search, reads the name and caches it in the package globals (persistence/__init__.py:181-190).
  • search is patched first. When monkeypatch.setattr(persistence, ...) then reads the old value, __getattr__ fetches the already patched stub from search and caches it. Monkeypatch records the stub as the original and "restores" it at teardown.
  • A later from repowise.core.persistence import FullTextSearch gets the stub.

Repro

pytest tests/unit/pipeline/test_incremental_persist_step_order.py tests/unit/cli/test_update_persist_reliability.py
E   AttributeError: '_FTS' object has no attribute 'index'
FAILED ...::test_update_sweeps_pages_retired_since_the_index_was_built
FAILED ...::test_full_update_leaves_no_rows_for_a_deleted_file
2 failed, 24 passed

test_update_persist_reliability.py alone: 19 passed.

Done looks like

  • Patch persistence before search, or read persistence.FullTextSearch once before patching, so the recorded original is the real class. Add a comment naming the lazy export.
  • Must not change: what the step-order tests assert.
  • First issue: test helper only.

Tests

The two-file command above passes. Optionally, a check in the helper that persistence.FullTextSearch is the real class after teardown.

Dominant language
Python
Stars
7.1k
Forks
756
Avg merge
21h 5m
Merged PRs (30d)
797

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from repowise-dev/repowise

All issues in repowise-dev/repowise

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.