Commit 6b6e54c
test(lfx): guard knowledge-deps probe against the chroma sys.modules shim
The module-level ``find_spec("langchain_chroma")`` crashed collection of the
whole lfx suite with ``ValueError: langchain_chroma.__spec__ is None``. The
KB-backends conftest registers a bare ``types.ModuleType("langchain_chroma")``
shim into ``sys.modules`` when the real package is absent; that shim satisfies
the knowledge module's ``from langchain_chroma import Chroma`` (so it imports),
but its ``__spec__`` is None, which makes ``find_spec`` raise rather than return
a spec. Running the file alone passed (no conftest, no shim); the full
``make lfx_tests`` failed.
Probe via a helper that checks ``sys.modules`` first and guards ``find_spec``
with ``except (ImportError, ValueError)`` — the same pattern the conftest's own
``_is_missing`` uses — so a shimmed, a real, and an absent langchain_chroma all
resolve correctly. Not flakiness and nothing was removed: purely the probe
tripping over another suite's fixture.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 0ce85f6 commit 6b6e54c
1 file changed
Lines changed: 30 additions & 7 deletions
Lines changed: 30 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
25 | 48 | | |
26 | 49 | | |
27 | 50 | | |
| |||
0 commit comments