The mojibake in8518114survived a green suite, and not by omission. There is a test called `test_a_stream_is_proxied_verbatim_including_the_telemetry _comments` which passed for months against a proxy that was decoding the stream as ISO-8859-1 and re-encoding it as UTF-8. It asserted three ASCII substrings, and a test that only ever sees ASCII cannot observe a charset bug. Two separate lies, both now fixed. The fakes. `iter_lines` yielded `self._lines` unchanged in both modes, so a test holding str lines got those str back even under decode_unicode -- a model of a stream that had ALREADY been decoded correctly. A fake that hands back the right answer cannot reproduce a decode bug. They now treat the wire as UTF-8 bytes whatever the test wrote, derive `encoding` from Content-Type using requests' own `get_encoding_from_headers`, and default to the charset-less `text/event-stream` OpenRouter really sends. The hostile case is the default, so a broken passthrough can no longer look correct. The assertions. The verbatim test now compares BYTES against every line the provider emitted, and the shared STREAM_LINES sample carries a raw UTF-8 em dash, so the whole streaming surface fails if the proxy ever goes back to decoding and re-encoding. Measured, by reverting8518114and running the suite: before this commit 1 test caught it (the one written for it) after 2, incl. the verbatim test that had been lying The dedicated regression test also gets simpler -- it no longer needs a bespoke response subclass, because the shared fake is now faithful enough. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VRQXz5SYZYVWscxS1QqF6U
8.5 KiB
8.5 KiB