You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Problems with the warningregistry() decorator in Lib/unittest/test/test_loader.py #79133
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2018-10-10.13:14:12.709>labels= ['3.8', '3.7', 'tests']
title='Problems with the warningregistry() decorator in Lib/unittest/test/test_loader.py'updated_at=<Date2018-10-10.13:15:59.662>user='https://github.com/serhiy-storchaka'
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 bpo-27063, but now I am not sure that it works as intended. Tests continue to pass after removing it.
The warningregistry() decorator no longer exists. It was removed in c834c02 (GH-92556) together with the deprecated load_tests aliases whose deprecation warnings it was meant to contain, so both problems are moot.
Activity
serhiy-storchaka commentedon Oct 10, 2018
There are other issues in the warningregistry() decorator in Lib/unittest/test/test_loader.py.
It contains a code:
The problem is that the condition
saved is missingis always false. If warningregistry was absent, saved ismissing.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 bpo-27063, but now I am not sure that it works as intended. Tests continue to pass after removing it.
serhiy-storchaka commentedon Oct 10, 2018
The decorator was added in bpo-16662.
serhiy-storchaka commentedon Aug 8, 2026
The
warningregistry()decorator no longer exists. It was removed in c834c02 (GH-92556) together with the deprecatedload_testsaliases whose deprecation warnings it was meant to contain, so both problems are moot.