Skip to content

Commit d234e0d

Browse files
committed
Don't use global storage for tokens since that looks like refleaks
1 parent 2de9fde commit d234e0d

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

Lib/test/test_asyncio/__init__.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
# Skip tests if we don't have concurrent.futures.
66
support.import_module('concurrent.futures')
7-
module_deprecation_tokens = set()
87

98

109
def load_tests(loader, _, pattern):
@@ -21,26 +20,18 @@ class AsyncioTestSuite(unittest.TestSuite):
2120
would be tedious, let's run this once and for all.
2221
"""
2322
def run(self, result, debug=False):
23+
ignore = support.ignore_deprecations_from
24+
tokens = {
25+
ignore("asyncio.base_events", like=r".*loop argument.*"),
26+
ignore("asyncio.unix_events", like=r".*loop argument.*"),
27+
ignore("asyncio.futures", like=r".*loop argument.*"),
28+
ignore("asyncio.runners", like=r".*loop argument.*"),
29+
ignore("asyncio.subprocess", like=r".*loop argument.*"),
30+
ignore("asyncio.tasks", like=r".*loop argument.*"),
31+
ignore("test.test_asyncio.test_queues", like=r".*loop argument.*"),
32+
ignore("test.test_asyncio.test_tasks", like=r".*loop argument.*"),
33+
}
2434
try:
25-
setUpModule()
2635
super().run(result, debug=debug)
2736
finally:
28-
tearDownModule()
29-
30-
31-
def setUpModule():
32-
ignore = support.ignore_deprecations_from
33-
module_deprecation_tokens.update((
34-
ignore("asyncio.base_events", like=r".*loop argument.*"),
35-
ignore("asyncio.unix_events", like=r".*loop argument.*"),
36-
ignore("asyncio.futures", like=r".*loop argument.*"),
37-
ignore("asyncio.runners", like=r".*loop argument.*"),
38-
ignore("asyncio.subprocess", like=r".*loop argument.*"),
39-
ignore("asyncio.tasks", like=r".*loop argument.*"),
40-
ignore("test.test_asyncio.test_queues", like=r".*loop argument.*"),
41-
ignore("test.test_asyncio.test_tasks", like=r".*loop argument.*"),
42-
))
43-
44-
45-
def tearDownModule():
46-
support.clear_ignored_deprecations(*module_deprecation_tokens)
37+
support.clear_ignored_deprecations(*tokens)

0 commit comments

Comments
 (0)