-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
gh-128438: Add EnvironmentVarGuard
for test_urllib
, test_urllib2.py
and urllib2_localnet.py
#128439
base: main
Are you sure you want to change the base?
Conversation
The tests that use If you find other tests that mess with |
👍 , feel free to close this one. Sorry for noise |
No worries! For instance |
Would it be fine to update all those places across multiple files in a single PR then? |
Other tests such as |
If there are not a lot of files and the changes are not too large, I'd say yes. If there are a lot of files, I'd prefer multiple PRs but one issue. |
👍 , will look into that. |
Updated issue title to reflect what is going to be done |
I'm converting this one to a draft until you commit what you found (so that reviewers are not attracted to it) |
So I have spent some time on this and identified files worth looking into: test_urllib.py Would you like to have PR for each or all together? From what I've seen there are quite a few places to change so probably split them into separate PRs? Maybe couple files per each one? WDYT? |
Let's have one PR per file and re-use the same issue. If the changes are identical (namely we change the same env var for the same reasons but in multiple files) but is spread across files, you can keep them in one PR. Otherwise one PR per file. For instance, the urllib2 tests can be grouped in one PR |
…ing with `os.environ`
This reverts commit 78525d16f842104ab33aa1dac2ef2691a07e18fa.
…lly messing with `os.environ`" This reverts commit 52b96f15b3ac2ccfefa9d8245c92145f6413441a.
…ib2_localnet.py`
8734b59
to
54f3010
Compare
EnvironmentVarGuard
in test_cmd_line
instead of manually messing with os.environ
EnvironmentVarGuard
for test_urllib
, test_urllib2.py
, urllib2_localnet.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definitely looks better!
EnvironmentVarGuard
for test_urllib
, test_urllib2.py
, urllib2_localnet.py
EnvironmentVarGuard
for test_urllib
, test_urllib2.py
and urllib2_localnet.py
On Windows, it appears that the |
Im guessing here (I dont have windows system to reproduce and test) but IIRC environment variables on Windows are not case sensitive. Setting value in Lines 777 to 778 in 513a4ef
So when |
Okay, seems like that did not help. This time there is no env diff reported though. Anyway we should probably just skip it on Windows? But it used to pass earlier which makes me wonder if it used to pass on accident or it was designed to work on Windows too. |
Mmh, maybe something else is happening. We need to investigate first (I don't have time today sorry :() and maybe ask some Windows experts. |
Okay so I guess I found the issue. If we look back at how environ was mocked: cpython/Lib/test/test_urllib.py Line 263 in 513a4ef
It was never behaving as proper environ, so it was case sensitive all the time, therefore it passed on Windows. Now we switched to proper environ and therefore case insensitivity breaks this test. So basically this test is pointless on Windows as there is no case sensitivity. BTW, my latest test commit proves that
WDYT? |
EnvironmentVarGuard
in tests instead of manually messing withos.environ
#128438