diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2018-08-11 06:05:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-11 06:05:04 (GMT) |
commit | 84a13fbda0d79789e3c9efcc9f64752261ce1e8d (patch) | |
tree | 5cc443f7bbfde403e0f7a731b5fda5fb4f54676a /Lib/test/support | |
parent | 423d05f6f59b24c91b9ef6b2e4ac130316764382 (diff) | |
download | cpython-84a13fbda0d79789e3c9efcc9f64752261ce1e8d.zip cpython-84a13fbda0d79789e3c9efcc9f64752261ce1e8d.tar.gz cpython-84a13fbda0d79789e3c9efcc9f64752261ce1e8d.tar.bz2 |
bpo-9372: Deprecate several __getitem__ methods (GH-8609)
The __getitem__ methods of DOMEventStream, FileInput,
and FileWrapper classes ignore their 'index' parameters
and return the next item instead.
Diffstat (limited to 'Lib/test/support')
-rw-r--r-- | Lib/test/support/__init__.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index d8dabd4..13b60f7 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -89,6 +89,7 @@ __all__ = [ "requires_IEEE_754", "skip_unless_xattr", "requires_zlib", "anticipate_failure", "load_package_tests", "detect_api_mismatch", "check__all__", "skip_unless_bind_unix_socket", + "ignore_warnings", # sys "is_jython", "is_android", "check_impl_detail", "unix_shell", "setswitchinterval", @@ -138,6 +139,22 @@ def _ignore_deprecated_imports(ignore=True): yield +def ignore_warnings(*, category): + """Decorator to suppress deprecation warnings. + + Use of context managers to hide warnings make diffs + more noisy and tools like 'git blame' less useful. + """ + def decorator(test): + @functools.wraps(test) + def wrapper(self, *args, **kwargs): + with warnings.catch_warnings(): + warnings.simplefilter('ignore', category=category) + return test(self, *args, **kwargs) + return wrapper + return decorator + + def import_module(name, deprecated=False, *, required_on=()): """Import and return the module to be tested, raising SkipTest if it is not available. |