Commit 25b411f
fix: stop two test modules from mutating global state at import time (#971)
* fix: scope the MAX_INPUT_LENGTH override to this test module
The module set qwen3_embed.common.utils.MAX_INPUT_LENGTH = 100 at import
time. pytest imports every test module during collection, so the override
survived into every other module in the session -- including the ones
deselected by -m, which are imported all the same. Five integration tests
failed with 'exceeds maximum allowed length of 100 characters' on inputs
that are nowhere near any real limit.
The comment justifying it was wrong: check_input_length reads the global
at call time, so it does not need to be set before the modules under test
are imported. tests/test_utils.py already patches it per-test with
monkeypatch.setattr. An autouse fixture does the same here and lets
monkeypatch restore it afterwards.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix: stop injecting a fake llama_cpp into sys.modules for the whole session
The module assigned sys.modules['llama_cpp'] = MagicMock() at import
time. Because pytest imports every test module during collection, the
fake outlived this file and was still in place when
tests/test_integration_gguf.py ran its pytest.importorskip('llama_cpp').
The guard found the fake, declined to skip, and 18 integration tests ran
against a mock and failed -- turning 'the optional backend is not
installed' into 'the backend is broken', which is the opposite reading.
qwen3_embed.text.gguf_embedding imports llama_cpp lazily inside
functions, so importing it needs no mock at all. The tests that do need
one already scope it with patch.dict(sys.modules, ...), the pattern
tests/test_gguf_cross_encoder.py uses.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent d9dc0be commit 25b411f
2 files changed
Lines changed: 24 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 14 | + | |
19 | 15 | | |
20 | 16 | | |
21 | 17 | | |
22 | 18 | | |
23 | 19 | | |
24 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
9 | 20 | | |
10 | 21 | | |
11 | 22 | | |
| |||
0 commit comments