-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
bpo-37411: Rewrite test_wsgiref.testEnviron() #14394
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
Conversation
Fix test_wsgiref.testEnviron() to no longer depend on the environment variables (don't fail if "X" variable is set). testEnviron() now overrides os.environ to get a deterministic environment. Test full TestHandler.environ content: not only a few selected variables.
|
@tirkarthi: Would you be interested to review my PR? |
| # set by BaseHandler.setup_environ() | ||
| 'wsgi.input': handler.get_stdin(), | ||
| 'wsgi.errors': handler.get_stderr(), | ||
| 'wsgi.version': (1, 0), |
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.
Clarification : Is it okay to let these values to be taken from handler's attributes so that the tests don't have to worry about these default values being changed in future? Since we just need to check handler.wsgi_version is set correctly with
cpython/Lib/wsgiref/handlers.py
Line 160 in c6a2320
| env['wsgi.version'] = self.wsgi_version |
Something like below :
'wsgi.input': handler.get_stdin(),
'wsgi.errors': handler.get_stderr(),
'wsgi.version': handler.wsgi_version,
'wsgi.run_once': handler.wsgi_run_once,
'wsgi.url_scheme': handler.get_scheme(),
'wsgi.multithread': handler.wsgi_multithread,
'wsgi.multiprocess': handler.wsgi_multiprocess,
'wsgi.file_wrapper': util.FileWrapper,
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.
I made a deliberate choice of copy directly the expected value rather than "reimplement" the logic creating the environ dictionary. I don't expect that default values will change often. If they change, well, the CI will tell you that and it will be trivial to update the tests.
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.
@tirkarthi: the test already checks that wsgi_xxx attributes are copied to wsgi.xxx env vars. I exchanged the two tests in testEnviron() so attributes are checked before hardcoded values. Are you fine with hardcoded values? Or do you prefer that I explicitly copy wsgi_xxx attributes?
tirkarthi
left a comment
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.
LGTM. Thanks Victor for the details.
|
test_asyncio failed on AppVeyor. I manually scheduled a rebuild. |
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.7, 3.8. |
Fix test_wsgiref.testEnviron() to no longer depend on the environment variables (don't fail if "X" variable is set). testEnviron() now overrides os.environ to get a deterministic environment. Test full TestHandler.environ content: not only a few selected variables. (cherry picked from commit 5150d32) Co-authored-by: Victor Stinner <[email protected]>
|
GH-14402 is a backport of this pull request to the 3.8 branch. |
|
GH-14403 is a backport of this pull request to the 3.7 branch. |
Fix test_wsgiref.testEnviron() to no longer depend on the environment variables (don't fail if "X" variable is set). testEnviron() now overrides os.environ to get a deterministic environment. Test full TestHandler.environ content: not only a few selected variables. (cherry picked from commit 5150d32) Co-authored-by: Victor Stinner <[email protected]>
|
GH-14404 is a backport of this pull request to the 2.7 branch. |
Fix test_wsgiref.testEnviron() to no longer depend on the environment variables (don't fail if "X" variable is set). testEnviron() now overrides os.environ to get a deterministic environment. Test full TestHandler.environ content: not only a few selected variables. (cherry picked from commit 5150d32) Co-authored-by: Victor Stinner <[email protected]>
Fix test_wsgiref.testEnviron() to no longer depend on the environment variables (don't fail if "X" variable is set). testEnviron() now overrides os.environ to get a deterministic environment. Test full TestHandler.environ content: not only a few selected variables. (cherry picked from commit 5150d32) Co-authored-by: Victor Stinner <[email protected]>
Fix test_wsgiref.testEnviron() to no longer depend on the environment variables (don't fail if "X" variable is set). testEnviron() now overrides os.environ to get a deterministic environment. Test full TestHandler.environ content: not only a few selected variables. (cherry picked from commit 5150d32) Co-authored-by: Victor Stinner <[email protected]>
) Fix test_wsgiref.testEnviron() to no longer depend on the environment variables (don't fail if "X" variable is set). testEnviron() now overrides os.environ to get a deterministic environment. Test full TestHandler.environ content: not only a few selected variables. (cherry picked from commit 5150d32) Co-authored-by: Victor Stinner <[email protected]>
Fix test_wsgiref.testEnviron() to no longer depend on the environment variables (don't fail if "X" variable is set). testEnviron() now overrides os.environ to get a deterministic environment. Test full TestHandler.environ content: not only a few selected variables.
Fix test_wsgiref.testEnviron() to no longer depend on the environment variables (don't fail if "X" variable is set). testEnviron() now overrides os.environ to get a deterministic environment. Test full TestHandler.environ content: not only a few selected variables.
Fix test_wsgiref.testEnviron() to no longer depend on the environment
variables (don't fail if "X" variable is set).
testEnviron() now overrides os.environ to get a deterministic
environment. Test full TestHandler.environ content: not only a few
selected variables.
https://bugs.python.org/issue37411