classification
Title: testEnviron (test.test_wsgiref.HandlerTests) fails when environment variable X is set
Type: Stage: resolved
Components: Tests Versions: Python 3.9, Python 3.8, Python 3.7, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: hroncok, miss-islington, vstinner, xtreak
Priority: normal Keywords: patch

Created on 2019-06-26 12:05 by hroncok, last changed 2019-07-03 09:31 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 14394 merged vstinner, 2019-06-26 13:29
PR 14402 merged miss-islington, 2019-06-26 16:16
PR 14403 merged miss-islington, 2019-06-26 16:16
PR 14404 merged miss-islington, 2019-06-26 16:17
Messages (7)
msg346605 - (view) Author: Miro Hrončok (hroncok) * Date: 2019-06-26 12:05
In Fedora CI, we use the environment variable X to set tests to skip:

https://src.fedoraproject.org/tests/python/blob/bd3ec9505cd37d80fe47fbb8234928abcfc0c658/f/selftest/parallel.sh#_9 - lines 9 and 21

However, I'Ve realized that testEnviron (test.test_wsgiref.HandlerTests) fails.

Here's a reproducer:

$ python3.7 -m test test_wsgiref 
Run tests sequentially
0:00:00 load avg: 0.75 [1/1] test_wsgiref

== Tests result: SUCCESS ==

1 test OK.

Total duration: 77 ms
Tests result: SUCCESS


$ X=boom python3.7 -m test test_wsgiref 
Run tests sequentially
0:00:00 load avg: 0.71 [1/1] test_wsgiref
test test_wsgiref failed -- Traceback (most recent call last):
  File "/usr/lib64/python3.7/test/test_wsgiref.py", line 567, in testEnviron
    self.checkOSEnviron(h)
  File "/usr/lib64/python3.7/test/test_wsgiref.py", line 559, in checkOSEnviron
    self.assertEqual(env[k],v)
AssertionError: 'Y' != 'boom'
- Y
+ boom


test_wsgiref failed

== Tests result: FAILURE ==

1 test failed:
    test_wsgiref

Total duration: 73 ms
Tests result: FAILURE


I believe that such tests should not be so easily fooled - it should be properly isolated or a less common variable name should be used if that is not possible, such as PYTHON_TEST_WSGIREF_TMP instead of X.
msg346615 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-26 13:32
I wrote PR 14394 to fix the test.
msg346649 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-26 16:16
New changeset 5150d327924959639215ed0a78feffc0d88258da by Victor Stinner in branch 'master':
bpo-37411: Rewrite test_wsgiref.testEnviron() (GH-14394)
https://github.com/python/cpython/commit/5150d327924959639215ed0a78feffc0d88258da
msg346670 - (view) Author: miss-islington (miss-islington) Date: 2019-06-26 19:38
New changeset 814c7aefc2b8e9892bce3d59c0ab39563d658aa2 by Miss Islington (bot) in branch '3.7':
bpo-37411: Rewrite test_wsgiref.testEnviron() (GH-14394)
https://github.com/python/cpython/commit/814c7aefc2b8e9892bce3d59c0ab39563d658aa2
msg346671 - (view) Author: miss-islington (miss-islington) Date: 2019-06-26 19:38
New changeset bdbd5e895ddf9aefcb79cdc52341f0697ad6aea0 by Miss Islington (bot) in branch '3.8':
bpo-37411: Rewrite test_wsgiref.testEnviron() (GH-14394)
https://github.com/python/cpython/commit/bdbd5e895ddf9aefcb79cdc52341f0697ad6aea0
msg346679 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-26 20:54
New changeset dfa9499ccbc14a4227ca8d0c1728e2beacbb45c6 by Victor Stinner (Miss Islington (bot)) in branch '2.7':
[2.7] bpo-37411: Rewrite test_wsgiref.testEnviron() (GH-14394) (GH-14404)
https://github.com/python/cpython/commit/dfa9499ccbc14a4227ca8d0c1728e2beacbb45c6
msg346680 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-26 20:55
Ok, the bug is now fixed in 2.7, 3.7, 3.8 and master branches. Thanks Miro for the report. I also enhanced the test to test all variables of handler.environ.
History
Date User Action Args
2019-07-03 09:31:21vstinnersetpull_requests: - pull_request14383
2019-07-03 01:56:10shihai1991setpull_requests: + pull_request14383
2019-07-02 21:01:39vstinnersetpull_requests: - pull_request14375
2019-07-02 16:42:24shihai1991setpull_requests: + pull_request14375
2019-06-28 17:08:58xtreaksetpull_requests: - pull_request14269
2019-06-28 17:02:09shihai1991setpull_requests: + pull_request14269
2019-06-26 20:55:23vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg346680

stage: patch review -> resolved
2019-06-26 20:54:31vstinnersetmessages: + msg346679
2019-06-26 19:38:28miss-islingtonsetmessages: + msg346671
2019-06-26 19:38:00miss-islingtonsetnosy: + miss-islington
messages: + msg346670
2019-06-26 16:17:08miss-islingtonsetpull_requests: + pull_request14216
2019-06-26 16:16:57miss-islingtonsetpull_requests: + pull_request14215
2019-06-26 16:16:48miss-islingtonsetpull_requests: + pull_request14214
2019-06-26 16:16:39vstinnersetmessages: + msg346649
2019-06-26 13:33:17vstinnersetversions: + Python 2.7, - Python 3.6
2019-06-26 13:32:41vstinnersetmessages: + msg346615
2019-06-26 13:29:47vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request14208
2019-06-26 13:06:36xtreaksetnosy: + xtreak
2019-06-26 12:05:51hroncokcreate