Skip to content

test is_https_redirect via public api - #3064

Merged
lovelydinosaur merged 4 commits into
encode:masterfrom
T-256:is_https_redirect
Feb 23, 2024
Merged

lovelydinosaur merged 4 commits into
encode:masterfrom
T-256:is_https_redirect

Conversation

@T-256

@T-256 T-256 commented Jan 16, 2024

Copy link
Copy Markdown
Contributor

Summary

chunk of #2851

Comment thread tests/test_utils.py
)

client = httpx.Client()
headers = client._redirect_headers(request, url, "GET")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm. Is there a way around that allows us to test this against public API?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be that we're okay with leaning on implementation details a little bit, certainly not a terrible trade-off to make. (I think we already have some instances of this in our test cases right?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we already use private-accessors in another test:

def test_proxy_with_mounts():
proxy_transport = httpx.HTTPTransport(proxy="http://127.0.0.1")
client = httpx.Client(mounts={"http://": proxy_transport})
transport = client._transport_for_url(httpx.URL("http://example.com"))
assert transport == proxy_transport

Comment thread tests/test_utils.py Outdated

@lovelydinosaur lovelydinosaur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay thanks. We're still using private API here, but I do think it's a little neater anyways since it nearly gets us to consistent imports all the way through the tests.

@lovelydinosaur
lovelydinosaur merged commit e745060 into encode:master Feb 23, 2024
@lovelydinosaur lovelydinosaur added the refactor Issues and PRs related to code refactoring label Feb 23, 2024
shepilov-vladislav pushed a commit to shepilov-vladislav/httpx that referenced this pull request Mar 28, 2024
* test `is_https_redirect` via public api

* Update tests/test_utils.py
samclearman pushed a commit to titanmsp/httpx that referenced this pull request Apr 26, 2025
* test `is_https_redirect` via public api

* Update tests/test_utils.py
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

Development

Successfully merging this pull request may close these issues.

2 participants