Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor test cases that import from private namespace. #2492

Open
tomchristie opened this issue Dec 6, 2022 · 5 comments
Open

Refactor test cases that import from private namespace. #2492

tomchristie opened this issue Dec 6, 2022 · 5 comments
Labels
refactor Issues and PRs related to code refactoring

Comments

@tomchristie
Copy link
Member

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.

@tomchristie tomchristie added the refactor Issues and PRs related to code refactoring label Dec 6, 2022
@tomchristie
Copy link
Member Author

Similar... can we also avoid/drop uses of mock.patch(...)?

@tomchristie
Copy link
Member Author

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

@florimondmanca
Copy link
Member

florimondmanca commented Feb 5, 2023

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.

@tomchristie
Copy link
Member Author

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 (

@T-256
Copy link
Contributor

T-256 commented Jan 16, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Issues and PRs related to code refactoring
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants