GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tests: run the query_rewrite reconstruction checks from the repository alone by simin-yuan · Pull Request #17 · Neboy72/nexus-memory

Conversation

@simin-yuan

@simin-yuan simin-yuan commented Nov 1, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Nebojsa flagged this file in #15 (comment) — "a test that cannot fail for anyone else is worse than no test". He is right, and it is worse than the description suggests.

What was wrong

sys.path.insert(0, str(Path(__file__).resolve().parents[2].parent
                   / 'nexus-memory-test' / 'src'))
from nexus_memory import query_rewrite as qr
  1. That path is outside the repository: <parent-of-the-clone>/nexus-memory-test/src.
  2. The module is a script, not a test module. pytest imports it, the checks run at import time, and the file contributes zero tests to the run. A broken check can only show up as a collection error, never as a failing test with a name.

Before, measured

Clean clone, no sibling checkout, Python 3.11, only pytest and pytest-asyncio installed (tests/conftest.py puts src/ on sys.path, so the import itself works):

$ python -m pytest tests/test_query_rewrite_recon.py -q
no tests ran in 0.13s
$ echo $?
5

And where the neighbour does exist, the inserted path wins: tests/conftest.py appends src/, this file prepends the outside path, so the checks measure that other checkout rather than the code in the repository. Reproduced by planting a scratch module at that location and importing the same way the test did:

$ python - <<'PY'
import sys
from pathlib import Path
sys.path.insert(0, str(Path("tests/test_query_rewrite_recon.py").resolve().parents[2].parent
                   / "nexus-memory-test" / "src"))
import nexus_memory.query_rewrite as qr
print(qr.__file__)
PY
D:\nexus-memory-test\src\nexus_memory\query_rewrite.py

(That directory was created for the demonstration and deleted again; nothing was committed.)

After

  • No path outside the repository. The module imports nexus_memory through the ordinary source layout, the same way every other test does.
  • Every check is now a test_* function: 26 tests, counted like the rest of the suite, failing with a name.
  • Same cases, same expected values, same German comments.
  • NEXUS_REWRITE is set/cleared with monkeypatch instead of os.environ, so the module no longer leaves that variable set for whatever runs next in the same process.

Verification

Where main (586d300) this branch
Clean clone, Python 3.11, package not installed no tests ran (exit 5) 26 passed
Ubuntu, GitHub Actions 41352084725, Python 3.11, pip install -e . no tests ran, pytest exit=5 26 passed, pytest exit=0
Windows 11, Python 3.11, in-repo worktree no tests ran 26 passed

The test can still catch a regression — injected locally, never committed. Making _clean_output return its input unchanged:

$ git diff --stat src/            # after the injection
$ python -m pytest tests/test_query_rewrite_recon.py -q
FAILED tests/test_query_rewrite_recon.py::test_thinking_wrapper_stripped
FAILED tests/test_query_rewrite_recon.py::test_prefix_stripped
FAILED tests/test_query_rewrite_recon.py::test_quotes_stripped
FAILED tests/test_query_rewrite_recon.py::test_single_line
4 failed, 22 passed

Reverted, same command: 26 passed.

Full suite

Same worktree, same interpreter, same environment; only tests/test_query_rewrite_recon.py and CHANGELOG.md differ.

failed passed skipped time
main (586d300), this file unchanged 10 2471 57 1009.40s
this branch 10 2497 57 1076.06s

pytest tests/ --collect-only -q differs by exactly the 26 new test ids and nothing else. The 10 failures are the same 10 on both sides — the pre-existing environment failures here (test_catalog_admission_round2 ×2, TestWebhookStore ×3, test_collection_default_is_overridden_by_the_env_file, TestH10ReleaseGate ×3, test_behavior_public_url_accepted). Nothing under src/ changes, so the pin guard stays quiet.

Only tests/test_query_rewrite_recon.py and CHANGELOG.md are touched.

CI note

Both CI jobs are red on exactly one test, and that test is red on main right now:

FAILED tests/test_wave23_fixes.py::TestNr408PackageVersions::test_lockfile_version_consistent
       - AssertionError: assert '1.21.16' == '1.22.0'
audit:         1 failed, 2040 passed, 30 skipped in 87.74s
audit-windows: 1 failed, 2024 passed, 46 skipped in 975.01s

main is now 2e91139 chore(openclaw): 1.22.0, which bumped plugins/openclaw/package.json to 1.22.0 and left plugins/openclaw/package-lock.json at 1.21.16. The test asserts those two agree, so it fails on a plain checkout of main — verified locally at 2e91139, 1 failed in 1.11s — and therefore also on the merge commit GitHub builds for a PR (run 41357625504).

Nothing else fails. I did not touch the lockfile; that is a one-line change on main, unrelated to this test.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@simin-yuan
tests: run the query_rewrite reconstruction checks from the repositor…
de9adff
…y alone

`tests/test_query_rewrite_recon.py` put `<parent-of-the-clone>/nexus-memory-test/src`
on `sys.path` and imported `nexus_memory` through it. Two consequences:

- In a clone without that sibling directory the path is dead weight. The module was a
  script, so pytest imported it and reported zero tests for the file — a broken check
  could only appear as a collection error, never as a failing test.
- Where the sibling does exist, the inserted path takes precedence over `src/` (which
  `tests/conftest.py` appends in the same import), so the checks measured that other
  checkout instead of the code in the repository.

The import now goes through the ordinary source layout the rest of the suite uses, and
each check is a separate `test_*` function, so it is counted and fails like any other
test. Same cases, same expected values; environment variables are handled with
`monkeypatch` so the module no longer leaves `NEXUS_REWRITE` behind for other tests.
@simin-yuan simin-yuan mentioned this pull request Nov 1, 2026
Subprocess output decoding breaks on non-UTF-8 Windows locales: error paths raise AttributeError #15
Closed
@Neboy72
Neboy72 merged commit f8ee58c into Neboy72:main Nov 2, 2026
0 of 2 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Neboy72

Neboy72 commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Thanks, I measured the same thing here before merging.

  • tests/test_query_rewrite_recon.py on your branch (de9adff): 26 passed, pytest exit code 0.
  • The same file on main (2e91139): no tests ran, pytest exit code 5.
  • The diff is limited to that file and CHANGELOG.md, nothing under src/.

Merged. Your note about the lockfile is right: on main, plugins/openclaw/package.json says 1.22.0 while package-lock.json still says 1.21.16 in both places, and the repo test that compares them fails on a plain checkout. I fix that in a separate commit right after this merge.

If you want to keep going, the most useful next thing is anything that only shows up on Windows, because I cannot reproduce that here, and a test that only fails on your machine is a defect I never see. And if you run Nexus Memory yourself, tell me where it gets in your way. That is worth more to me than another green test.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Neboy72 pushed a commit that referenced this pull request Nov 16, 2026
@simin-yuan
tests: run the query_rewrite reconstruction checks from the repositor…
6621708
…y alone (#17)

`tests/test_query_rewrite_recon.py` put `<parent-of-the-clone>/nexus-memory-test/src`
on `sys.path` and imported `nexus_memory` through it. Two consequences:

- In a clone without that sibling directory the path is dead weight. The module was a
  script, so pytest imported it and reported zero tests for the file — a broken check
  could only appear as a collection error, never as a failing test.
- Where the sibling does exist, the inserted path takes precedence over `src/` (which
  `tests/conftest.py` appends in the same import), so the checks measured that other
  checkout instead of the code in the repository.

The import now goes through the ordinary source layout the rest of the suite uses, and
each check is a separate `test_*` function, so it is counted and fails like any other
test. Same cases, same expected values; environment variables are handled with
`monkeypatch` so the module no longer leaves `NEXUS_REWRITE` behind for other tests.
Neboy72 pushed a commit that referenced this pull request Nov 17, 2026
@simin-yuan
tests: run the query_rewrite reconstruction checks from the repositor…
276ebba
…y alone (#17)

`tests/test_query_rewrite_recon.py` put `<parent-of-the-clone>/nexus-memory-test/src`
on `sys.path` and imported `nexus_memory` through it. Two consequences:

- In a clone without that sibling directory the path is dead weight. The module was a
  script, so pytest imported it and reported zero tests for the file — a broken check
  could only appear as a collection error, never as a failing test.
- Where the sibling does exist, the inserted path takes precedence over `src/` (which
  `tests/conftest.py` appends in the same import), so the checks measured that other
  checkout instead of the code in the repository.

The import now goes through the ordinary source layout the rest of the suite uses, and
each check is a separate `test_*` function, so it is counted and fails like any other
test. Same cases, same expected values; environment variables are handled with
`monkeypatch` so the module no longer leaves `NEXUS_REWRITE` behind for other tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@simin-yuan @Neboy72
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.