Pull requests / #1048

#1048 serve tests: test_json_schema_text_format's schema failure only where jsonschema is installed

closed · @sergqwer · 0 comentários · No GitHub

Setup & installServer & APIWindows

Descrição

Replaces #785. GitHub closed it on 2026-10-05, when my fork was made private by mistake: that took the fork out of the network for good, so it can no longer open pull requests. This is the same branch and commit (`c1d63cc`), opened from a new fork; the discussion and the measurements are in #785.

---

`serve.test_responses.OverHttp.test_json_schema_text_format` fails on every install without `jsonschema`, including a clean v0.1.39:

```
self.assertEqual((code, r["error"]["code"]), (502, "structured_output_failed"))
TypeError: 'NoneType' object is not subscriptable
```

`jsonschema` is optional (`serve/structured.py`). Without it, a `json_schema` answer is only checked to be one JSON object. The test's "bad" case answers `{"n": 3}` against a schema that wants `n` as a string. That answer is a JSON object, so it passes with a 200 where the test expects the 502.

The test now checks the schema failure only when `jsonschema` imports, which is how `test_structured.py` already treats it (`HAVE_JSONSCHEMA`). Everything before that part of the test still runs either way.

Checked on Windows 11 with the server's venv, which has no `jsonschema`: `serve.test_responses` was 1 error before and is OK now.

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

https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio

No site

Links install, modelos, releases.