This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lukasz.langa
Recipients lukasz.langa
Date 2021-08-06.16:57:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
For example, all that's needed to silence the 220 new warnings in all asyncio tests, is adding this in Lib/test/test_asyncio/

def setUpModule():
    support.ignore_deprecations_from("asyncio.base_events", like=r".*loop argument.*")
    support.ignore_deprecations_from("asyncio.unix_events", like=r".*loop argument.*")
    support.ignore_deprecations_from("asyncio.futures", like=r".*loop argument.*")
    support.ignore_deprecations_from("asyncio.runners", like=r".*loop argument.*")
    support.ignore_deprecations_from("asyncio.subprocess", like=r".*loop argument.*")
    support.ignore_deprecations_from("asyncio.tasks", like=r".*loop argument.*")
    support.ignore_deprecations_from("test.test_asyncio.test_queues", like=r".*loop argument.*")
    support.ignore_deprecations_from("test.test_asyncio.test_tasks", like=r".*loop argument.*")

def tearDownModule():

Since the `` file in question isn't a module that runs tests itself but only a package gathering many sub-modules, we need some boilerplate like:

def load_tests(loader, _, pattern):
    pkg_dir = os.path.dirname(__file__)
    suite = AsyncioTestSuite()
    return support.load_package_tests(pkg_dir, loader, suite, pattern)

class AsyncioTestSuite(unittest.TestSuite):
    """A custom test suite that also runs setup/teardown for the whole package.

    Normally unittest only runs setUpModule() and tearDownModule() within each
    test module part of the test suite. Copying those functions to each file
    would be tedious, let's run this once and for all.
    def run(self, result, debug=False):
            super().run(result, debug=debug)

With that, all of asyncio tests silence unnecessary deprecation warnings. Additionally, testing for warnings with `warnings_helper.check_warnings()` or `assertWarns` still works just fine as those facilities temporarily disable filtering.
Date User Action Args
2021-08-06 16:57:50lukasz.langasetrecipients: + lukasz.langa
2021-08-06 16:57:50lukasz.langasetmessageid: <>
2021-08-06 16:57:50lukasz.langalinkissue44852 messages
2021-08-06 16:57:50lukasz.langacreate