New submission from Serhiy Storchaka <storchaka+cpyt...@gmail.com>:

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.

----------
components: Tests
messages: 327468
nosy: barry, ezio.melotti, michael.foord, rbcollins, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Problems with the warningregistry() decorator in 
Lib/unittest/test/test_loader.py
versions: Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34952>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to