8000 [3.7] gh-102950: Implement PEP 706 – Filter for tarfile.extractall (GH-102953) by encukou · Pull Request #104583 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.7] gh-102950: Implement PEP 706 – Filter for tarfile.extractall (GH-102953) #104583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Closed
Prev Previous commit
Next Next commit
Backport test.support.check_no_warnings
  • Loading branch information
encukou committed May 17, 2023
commit 300a1a82e1539b5d777f6f28baefe401267e4a54
24 changes: 24 additions & 0 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,30 @@ def check_warnings(*filters, **kwargs):
return _filterwarnings(filters, quiet)


@contextlib.contextmanager
def check_no_warnings(testcase, message='', category=Warning, force_gc=False):
"""Context manager to check that no warnings are emitted.

This context manager enables a given warning within its scope
and checks that no warnings are emitted even with that warning
enabled.

If force_gc is True, a garbage collection is attempted before checking
for warnings. This may help to catch warnings emitted when objects
are deleted, such as ResourceWarning.

Other keyword arguments are passed to warnings.filterwarnings().
"""
with warnings.catch_warnings(record=True) as warns:
warnings.filterwarnings('always',
message=message,
category=category)
yield
if force_gc:
gc_collect()
testcase.assertEqual(warns, [])


@contextlib.contextmanager
def check_no_resource_warning(testcase):
"""Context manager to check that no ResourceWarning is emitted.
Expand Down
0