From: Nikita Sobolev Date: Sat, 22 Jan 2022 11:06:27 +0000 (+0300) Subject: bpo-46425: fix direct invocation of `asyncio` tests (#30725) X-Git-Tag: v3.11.0a5~163 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5a5340044ca98cbe6297668d91bccba04b102923;p=thirdparty%2FPython%2Fcpython.git bpo-46425: fix direct invocation of `asyncio` tests (#30725) --- diff --git a/Lib/test/test_asyncio/test_context.py b/Lib/test/test_asyncio/test_context.py index 63b1eb320ce1..6b80721873d9 100644 --- a/Lib/test/test_asyncio/test_context.py +++ b/Lib/test/test_asyncio/test_context.py @@ -32,3 +32,7 @@ class DecimalContextTest(unittest.TestCase): self.assertEqual(str(r2[0]), '0.333333') self.assertEqual(str(r2[1]), '0.111111') + + +if __name__ == '__main__': + unittest.main() diff --git a/Lib/test/test_asyncio/test_futures2.py b/Lib/test/test_asyncio/test_futures2.py index 13dbc703277c..57d24190bc0b 100644 --- a/Lib/test/test_asyncio/test_futures2.py +++ b/Lib/test/test_asyncio/test_futures2.py @@ -16,3 +16,7 @@ class FutureTests(unittest.IsolatedAsyncioTestCase): # The check for returned string is not very reliable but # exact comparison for the whole string is even weaker. self.assertIn('...', repr(await asyncio.wait_for(func(), timeout=10))) + + +if __name__ == '__main__': + unittest.main() diff --git a/Lib/test/test_asyncio/test_protocols.py b/Lib/test/test_asyncio/test_protocols.py index 438111cccd34..d8cde6d89aad 100644 --- a/Lib/test/test_asyncio/test_protocols.py +++ b/Lib/test/test_asyncio/test_protocols.py @@ -55,3 +55,7 @@ class ProtocolsAbsTests(unittest.TestCase): self.assertIsNone(sp.pipe_connection_lost(1, f)) self.assertIsNone(sp.process_exited()) self.assertFalse(hasattr(sp, '__dict__')) + + +if __name__ == '__main__': + unittest.main() diff --git a/Lib/test/test_asyncio/test_runners.py b/Lib/test/test_asyncio/test_runners.py index b9ae02dc3c04..5c06a1aaa830 100644 --- a/Lib/test/test_asyncio/test_runners.py +++ b/Lib/test/test_asyncio/test_runners.py @@ -2,7 +2,7 @@ import asyncio import unittest from unittest import mock -from . import utils as test_utils +from test.test_asyncio import utils as test_utils class TestPolicy(asyncio.AbstractEventLoopPolicy): @@ -180,3 +180,7 @@ class RunTests(BaseTest): self.assertIsNone(spinner.ag_frame) self.assertFalse(spinner.ag_running) + + +if __name__ == '__main__': + unittest.main() diff --git a/Lib/test/test_asyncio/test_sendfile.py b/Lib/test/test_asyncio/test_sendfile.py index 0a5466a0af15..57b56bba3410 100644 --- a/Lib/test/test_asyncio/test_sendfile.py +++ b/Lib/test/test_asyncio/test_sendfile.py @@ -565,3 +565,7 @@ else: def create_event_loop(self): return asyncio.SelectorEventLoop(selectors.SelectSelector()) + + +if __name__ == '__main__': + unittest.main() diff --git a/Lib/test/test_asyncio/test_sock_lowlevel.py b/Lib/test/test_asyncio/test_sock_lowlevel.py index ab022a357d20..448d835b04d5 100644 --- a/Lib/test/test_asyncio/test_sock_lowlevel.py +++ b/Lib/test/test_asyncio/test_sock_lowlevel.py @@ -1,5 +1,4 @@ import socket -import time import asyncio import sys import unittest @@ -512,3 +511,7 @@ else: def create_event_loop(self): return asyncio.SelectorEventLoop(selectors.SelectSelector()) + + +if __name__ == '__main__': + unittest.main()