Index: Lib/test/test_support.py =================================================================== --- Lib/test/test_support.py (revision 77822) +++ Lib/test/test_support.py (working copy) @@ -29,7 +29,8 @@ "run_with_locale", "set_memlimit", "bigmemtest", "bigaddrspacetest", "BasicTestRunner", "run_unittest", "run_doctest", "threading_setup", "threading_cleanup", "reap_children", "cpython_only", - "check_impl_detail", "get_attribute", "py3k_bytes"] + "check_impl_detail", "get_attribute", "py3k_bytes", + "silence_py3k_warnings"] class Error(Exception): """Base class for regression test exceptions.""" @@ -483,6 +484,16 @@ with warnings.catch_warnings(record=True) as w: yield WarningsRecorder(w) +@contextlib.contextmanager +def silence_py3k_warnings(*filters): + with warnings.catch_warnings(): + if sys.py3kwarning: + if filters == (): + filters = (("", DeprecationWarning),) + for filter in filters: + warnings.filterwarnings("ignore", *filter) + yield + class CleanImport(object): """Context manager to force import to return a new module reference.