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: Problems with the warningregistry() decorator in Lib/unittest/test/test_loader.py
Type: Stage:
Components: Tests Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: barry, ezio.melotti, michael.foord, rbcollins, serhiy.storchaka
Priority: normal Keywords:

Created on 2018-10-10 13:14 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg327468 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-10 13:14
There are other issues in the warningregistry() decorator in Lib/unittest/test/test_loader.py.

It contains a code:

    missing = []
    saved = getattr(warnings, '__warningregistry__', missing).copy()
    ...
    if saved is missing:

The problem is that the condition `saved is missing` is always false. If __warningregistry__ was absent, saved is `missing.copy()` which is a new empty list. As result, warnings.__warningregistry__ is set to [] after the test if it did not exist before the test.

Other problem is that this decorator works with __warningregistry__ in the warnings module. It is changed only when warnings are emitted by the code of the warnings module. Is it intentional? I don't know any code that emits warnings in the warnings module.

It is hard to understand what was the intention of this decorator. From initial it was not working and cause the decorated tests be silently skipped. This was fixed in issue27063, but now I am not sure that it works as intended. Tests continue to pass after removing it.
msg327469 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-10 13:15
The decorator was added in issue16662.
History
Date User Action Args
2022-04-11 14:59:07adminsetgithub: 79133
2018-10-10 13:15:59serhiy.storchakasetmessages: + msg327469
2018-10-10 13:14:12serhiy.storchakacreate