#6492 [Other] tests: the first VisionTempFiles class was shadowed and never ran

open · @DamirLukina88 · 0 comentários · No GitHub

Setup & installServer & APIModels & quantsWindowsLinux

Descrição

## Problem and result

`terminal/serve/test_server.py` defines two classes named `VisionTempFiles` (lines 292 and 555). The second definition replaces the first, so the first class's two tests never ran: `test_a_refused_request_writes_none` and `test_over_http`. They check that a request's combined image file (`req-*.sve`, about 10 MB a picture) is not left behind by a refused request. On `main`, `pytest --collect-only` lists none of them.

After the rename both tests are collected again. They needed two updates to match the current server, and now pass:
- since #874 the file goes to `/dev/shm` on Linux when that has room, so `leftovers()` looks there as well as in the vision directory (guarded by `is_dir()`, so Windows and macOS see only the vision directory, as before). The `/dev/shm` name carries only the process id, so `setUp()` takes a snapshot of what earlier tests in the same process left there, and only files new since then count;
- since `fit_max_tokens` is on by default, a `max_tokens` that does not fit is shortened instead of refused, so the one assertion that expects the "exceeds the context" refusal turns `fit_max_tokens` off around that call. The test's point stays the same: a refused request writes no file.

## Related discussion

none (a test-only fix)

## Approach

The first class is renamed `VisionRequestFiles`, after what it tests. The test-only change is 13 lines added and 3 removed in one file, and no server code changes.

## Validation

**Passed:**
- `python -m pytest --collect-only -q terminal/serve/test_server.py` on `main` at 3142b66b9: `VisionTempFiles` lists 6 tests and `VisionRequestFiles` none (the class does not exist). On this branch: `VisionRequestFiles` lists 2 more tests, 447 in total instead of 445.
- `python -m pytest -q terminal/serve/test_server.py -k "VisionRequestFiles or VisionTempFiles"` on this branch: 8 passed.
- The two updates are both needed. After the rename alone, `test_a_refused_request_writes_none` fails at the "exceeds the context" assertion (`ValueError not raised`). With the `fit_max_tokens` change but without the `/dev/shm` lookup, it fails at `assertEqual(len(self.leftovers(d)), 1)` with `0 != 1`.
- The `/dev/shm` snapshot (added after review): `python -m unittest serve.test_server` from `terminal/` runs `ImageMarkers` before these tests, and that class leaves request files in `/dev/shm`. Without the snapshot (805c2bda8), both restored tests fail in that run (447 run, 2 failures). With it (5dbd5ac0d), all 447 pass. Also checked with a planted `strata-vision-<pid>-req-*.sve` file: 2 failures without the snapshot, OK with it.
- `python tools/check --only py-serve` on 805c2bda8: 2056 passed, 26 skipped (Windows-only tests, no pack tokenizer, jsonschema and the anthropic package not installed, no puppeteer), and 1 failed. The failure was `test_parallel_yield.ParallelServiceYield::test_a_long_prompt_gives_way_to_a_short_one`, a timing assertion (`short < long - 0.5 s`) that failed while an engine build was running on the same machine. That file is not touched here, and `python -m pytest -q serve/test_parallel_yield.py` passed 20 of 20 in three runs afterwards.

Environment: CachyOS Linux, Python 3.14, `/dev/shm` a 16 GB tmpfs.

**Failed:**
none caused by this change (the timing test above, under load, in a file this PR does not touch)

**Not run:**
Windows and macOS. The `/dev/shm` lookup is skipped where that folder does not exist, and the PR's CI runs both.

## Limits

none

🤖 Generated with [Claude Code](https://claude.com/claude-code)

No site

Links install, modelos, releases.