-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Pass the session's proxies property to request #10680
Conversation
After waiting a long time for a fix on the side of the request that could fix pip install issues with proxy as already discussed in pypa#9691. It seems that such changes as mentioned in psf/requests#5735 will take a while to happen, probably only on version 3 of the request. Therefore, I'm suggesting a change on the pip side as already proposed in [issuecomment-79051687]pypa#9568 (comment) and [issuecomment-939373868]psf/requests#5735 (comment) I think it's important that pip address this issue asap since the newer versions of pip are not working properly behind a proxy.
This needs a test, to ensure that (a) it fixes the issue, and (b) we don't introduce regressions with future changes. |
Do we have tests for any sort of proxy logic? If not, it might be fine to merge this as-is. 💁🏽 That said, there’s no version of this where having an actual test written is problematic, so it would 100% be a good idea to have one here. |
I don't know enough myself about proxy handling to be sure it's correct without a test, but I'm fine if someone else wants to merge it as is. |
Suggestion for testing proxy. A valid proxy must be provided so this test can work.
Hello @pfmoore and @pradyunsg I've added (committed) a test_proxy in test_network_session.py. @pfmoore I don't know what do you mean by "we don't introduce regressions with future changes.". What kind of regression is introduced by these changes? Would be nice if you could clarify this better. :). I hope this can help somehow to remove the bug with proxy introduced by request. |
That's not how the tests need to work. You'd need to have some sort of mock proxy as part of the test suite in order to ensure that people (or the CI!) without a proxy available can still run the test.
I mean that when someone else comes along and changes the networking code, we need to be sure that they don't break things again. The best (only) way to do that is if we have something in the test suite that checks the new code you added, and confirms it's working, Then if someone later breaks proxy support, the test suite will fail and they will find out. |
Simulating the behavior of a proxy is a complicated matter. If it is possible to import third-party libraries into the tests, the most efficient way is to create a real proxy server. |
Fixing indentation
@pfmoore Thank you for your clarification. I'm sorry for the previous error, I just realized there was an indentation problem on the test committed since I just copy and paste my local changes directly on the raw file on Github. I will clone this branch so that doesn't happen again...sorry |
The change looks good to me. Can you add Also please add a news entry for this. |
Given the provided test will always fail on our CI, it's not much use IMO (anyone who can manually set a proxy to exercise the test can probably also set their proxy and just try pip out, after all...). My main intention in asking for a test was so that people without the ability to set up a proxy would be covered, because the test would run in CI to ensure this functionality still worked. Question for the other @pypa/pip-committers - do we want to include this change without it being tested by our CI? I'm ambivalent. The change is simple enough that asking for a test is making the whole PR turn into a much bigger exercise than it should be1. But on the other hand, if we do ever switch to another network library like httpx, how will we know that proxy support still works if we have no test? Footnotes
|
I think we should; if we don’t want to add anything non-testable, we should’ve not supported proxies to begin with 🙂 |
What about an integration test where a simple proxy is set up and then it tests that it can use it to say download? I'm experimenting with it now, would you be interested with in a PR if I get it working okay? |
I take it that #10901 is the PR. |
Yes |
- Added --proxy parameter to pytest
Hi everyone, I have updated the test_network_session and added the Now the test works as follow:
Examples of how to run: @uranusjr I know you ask me to add a news entry, but I'm not sure how/what exactly should I add. I know there is a |
It is my pleasure @pfmoore to help and give a small contribution to such an important package to the python community as pip. |
Happy to! Please see https://pip.pypa.io/dev/news-entry-failure. This is mentioned in the CI failure for the news file check as well, although that hadn't been run when you asked your question. :) |
- Reformatted code style in test
@pradyunsg Thank you. I've added a News entry 9691.bugfix.rst that makes reference to the issue #9691. Hope that's it. |
@pradyunsg Could you check if this version passes all the workflows' checks? Thanks |
Hi everyone, First I would like to thank you all for the support on this PR. |
After waiting a long time for a fix on the side of the request that could fix pip install issues with proxy as already discussed in #9691. It seems that such changes as mentioned in psf/requests#5735 will take a while to happen, probably only on version 3 of the request.
Therefore, I'm suggesting a change on the pip side as already proposed in #9568 (comment) and psf/requests#5735 (comment)
I think it's important that pip address this issue asap since the newer versions of pip are not working properly behind a proxy.