This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Running test_warnings twice fails
Type: Stage: resolved
Components: Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: vstinner
Priority: normal Keywords:

Created on 2017-06-30 09:43 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 2504 merged vstinner, 2017-06-30 10:46
PR 2507 merged vstinner, 2017-06-30 11:00
Messages (5)
msg297368 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-06-30 09:43
Example on Python 3.6:

haypo@selma$ ./python -m test test_warnings  test_warnings 
Run tests sequentially
0:00:00 load avg: 1.74 [1/2] test_warnings
0:00:01 load avg: 1.68 [2/2] test_warnings
/home/haypo/prog/python/3.6/Lib/test/test_warnings/__init__.py:902: UserWarning: foo
  wmod.warn("foo")
/home/haypo/prog/python/3.6/Lib/test/test_warnings/__init__.py:1000: UserWarning: foo
  wmod.warn("foo")
/home/haypo/prog/python/3.6/Lib/test/test_warnings/__init__.py:964: UserWarning: This is a warning
  wmod.warn(text)
/home/haypo/prog/python/3.6/Lib/test/test_warnings/__init__.py:986: UserWarning: This is a warning
  wmod.warn(text)
/home/haypo/prog/python/3.6/Lib/test/test_warnings/__init__.py:148: UserWarning: FilterTests.test_always
  self.module.warn(message, UserWarning)
/home/haypo/prog/python/3.6/Lib/test/test_warnings/__init__.py:159: UserWarning: FilterTests.test_always_after_ignore
  self.module.warn(message, UserWarning)
/home/haypo/prog/python/3.6/Lib/test/test_warnings/__init__.py:180: UserWarning: FilterTests.test_default
  self.module.warn(message, UserWarning)
/home/haypo/prog/python/3.6/Lib/test/test_warnings/__init__.py:249: UserWarning: handle normally
  self.module.warn(text)
/home/haypo/prog/python/3.6/Lib/test/test_warnings/__init__.py:135: UserWarning: FilterTests.test_ignore_after_default
  self.module.warn(message, UserWarning)
/home/haypo/prog/python/3.6/Lib/test/test_warnings/__init__.py:195: UserWarning: FilterTests.test_module
  self.module.warn(message, UserWarning)
f.py:42: UserWarning: b
__init__.py:42: UserWarning: FilterTests.test_once
/home/haypo/prog/python/3.6/Lib/test/test_warnings/data/stacklevel.py:9: UserWarning: spam1
  warnings.warn(message, stacklevel=stacklevel)
/home/haypo/prog/python/3.6/Lib/test/test_warnings/__init__.py:354: UserWarning: multi 0
  self.module.warn(text)
/home/haypo/prog/python/3.6/Lib/test/__main__.py:9: UserWarning: spam9
__main__:9: UserWarning: spam11
__main__:9: UserWarning: spam10
test.test_warnings.data.stacklevel:9: UserWarning: spam8
/home/haypo/prog/python/3.6/Lib/test/test_warnings/data/stacklevel.py:9: UserWarning: spam3
  warnings.warn(message, stacklevel=stacklevel)
/home/haypo/prog/python/3.6/Lib/test/test_warnings/__init__.py:415: DeprecationWarning: module-level warning
  import test.test_warnings.data.import_warning
nonasciié€:1: UserWarning: text
/home/haypo/prog/python/3.6/Lib/test/test_warnings/__init__.py:365: UserWarning: <class 'Warning'>
  self.module.warn(ob)
/home/haypo/prog/python/3.6/Lib/test/test_warnings/__init__.py:561: MyWarningClass: good warning category
  self.module.warn('good warning category', MyWarningClass)
<test>:42: UserWarning: defaultaction test
test.test_warnings:778: UserWarning: test
file:42: UserWarning: onceregistry test
/home/haypo/prog/python/3.6/Lib/test/test_warnings/__init__.py:741: UserWarning: Warning!
  self.module.warn('Warning!')
/home/haypo/prog/python/3.6/Lib/unittest/case.py:178: UserWarning: Warning!
  callable_obj(*args, **kwargs)
test test_warnings failed -- multiple errors occurred; run in verbose mode for details
test_warnings failed
1 test OK.

1 test failed:
    test_warnings

Total duration: 3 sec
Tests result: FAILURE
msg297369 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-06-30 09:47
I saw this bug on AMD64 Windows8.1 Refleaks 3.6:
"test test_warnings failed -- multiple errors occurred; run in verbose mode for details"
http://buildbot.python.org/all/builders/AMD64%20Windows8.1%20Refleaks%203.6/builds/38/steps/test/logs/stdio

The goal is to get a successful "./python -m test -R 3:3 -v test_warnings" run.
msg297372 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-06-30 10:49
Oh cool, my bisect tool identified the bug!

haypo@selma$ ./python -m test.bisect -o bisect test_warnings  test_warnings 
(...)
Tests (1):
* test.test_warnings._WarningsTests.test_showwarnmsg_missing
(...)
Bisection completed in 14 iterations and 0:00:14

So the bug is that test_showwarnmsg_missing() removes the warnings._showwarnmsg attribute, but don't restore it.

https://github.com/python/cpython/pull/2504 fixes the issue.
msg297379 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-06-30 10:58
New changeset 7eebeb8fb84e2a9cb73903a08c59cf1d3b32cee0 by Victor Stinner in branch 'master':
bpo-30812: Fix test_warnings, restore _showwarnmsg (#2504)
https://github.com/python/cpython/commit/7eebeb8fb84e2a9cb73903a08c59cf1d3b32cee0
msg297382 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-06-30 11:12
New changeset d0aac5da59b1bbd113e6081d7c807ad5bced8a05 by Victor Stinner in branch '3.6':
bpo-30812: Fix test_warnings, restore _showwarnmsg (#2504) (#2507)
https://github.com/python/cpython/commit/d0aac5da59b1bbd113e6081d7c807ad5bced8a05
History
Date User Action Args
2022-04-11 14:58:48adminsetgithub: 74995
2017-06-30 11:22:09vstinnersetstatus: open -> closed
resolution: fixed
stage: resolved
2017-06-30 11:12:14vstinnersetmessages: + msg297382
2017-06-30 11:00:00vstinnersetpull_requests: + pull_request2577
2017-06-30 10:58:49vstinnersetmessages: + msg297379
2017-06-30 10:49:03vstinnersetmessages: + msg297372
2017-06-30 10:46:57vstinnersetpull_requests: + pull_request2567
2017-06-30 09:47:35vstinnersetmessages: + msg297369
2017-06-30 09:43:34vstinnercreate