Open tomchristie opened 1 year ago
Similar... can we also avoid/drop uses of mock.patch(...)
?
Reminder to self...
Cases currently still left are these:
$ grep -r "from httpx" ./tests/*
./tests/client/test_proxies.py:from httpx._utils import URLPattern
./tests/conftest.py:from httpx import URL
./tests/conftest.py: from httpx._transports.asgi import _Receive, _Send
./tests/test_decoders.py:from httpx._compat import brotli
./tests/test_decoders.py:from httpx._decoders import ByteChunker, LineDecoder, TextChunker, TextDecoder
./tests/test_exceptions.py:from httpx._transports.default import HTTPCORE_EXC_MAP
./tests/test_exported_members.py:from httpx import __all__ as exported_members
./tests/test_main.py:from httpx import main
./tests/test_main.py: from httpx._main import main # noqa: F811
./tests/test_multipart.py:from httpx._content import encode_request
./tests/test_utils.py:from httpx._utils import (
./tests/utils.py:from httpx import _utils
I pushed a bunch of PRs which get most of the remaining refactoring done.
The last bits are in test/test_utils.py
, which unit test actual utility functions that I don't think are easy or relevant to test through public API.
Follow up from my previous comment...
$ grep -r "from httpx" ./tests/*
./tests/client/test_proxies.py:from httpx._utils import URLPattern
./tests/test_utils.py:from httpx._utils import (
Only test_utils.py
imports these private namespaces:
We have some test cases that import from private namespace inside
httpx
.This is clearly a code-smell, because our test cases ought to be tests against our public API, rather than testing implementation details. Perhaps there's some cases where it's a necessary hack, but... perhaps not?
It'd be worthwhile reviewing if we're able to remove all the cases where we're doing this. I'd suggest that any pull requests resolving this are handled on a one-module-at-a-time basis.