Support brotlicffi in tests
mgorny opened this issue · comments
While the package itself can work with either brotli
or brotlicffi
, tests/test_decoders.py
explicitly requires brotli
. We're currently working on having all packages support brotlicffi
in Gentoo, since brotli
doesn't work reliably on PyPy3. Could you please consider making the test accept brotlicffi
as well?
I suppose the simplest way would be to reuse the existing logic, i.e.:
from httpx._compat import brotli
I can submit a PR for that.
- Initially raised as discussion #2903
I can submit a PR for that.
Yes, that would be great!
Alternate options:
- We could just always
brotlicffi
in the tests instead ofbrotli
. (Because we value platform independence over c-performance here.) - We don't actually need the
brotli
dependency in the tests at all, so we could drop it outright. We only use it on 3 lines, each of which we can replace using the byte encoding directly...
- compressed_body = brotli.compress(body)
+ compressed_body = b"\x8b\x03\x80test 123\x03"
- body = b"test 123"
- compressed_body = brotli.compress(body)[3:]
+ compressed_body = b"invalid"
* We could just always `brotlicffi` in the tests instead of `brotli`. (Because we value platform independence over c-performance here.)
That would work for us since we care about brotlicffi
only but I think it'd be better to match the implementation used by httpx
in the more general case.
* We don't actually need the `brotli` dependency in the tests at all, so we could drop it outright. We only use it on 3 lines, each of which we can replace using the byte encoding directly...
Yeah, that would work for me.
Please let me know which approach you prefer and I can do it.
Please let me know which approach you prefer and I can do it.
I'd suggest the second.