[Python-checkins] bpo-46425: fix direct invocation of `asyncio` tests (#30725)

asvetlov webhook-mailer at python.org
Sat Jan 22 06:06:31 EST 2022


https://github.com/python/cpython/commit/5a5340044ca98cbe6297668d91bccba04b102923
commit: 5a5340044ca98cbe6297668d91bccba04b102923
branch: main
author: Nikita Sobolev <mail at sobolevn.me>
committer: asvetlov <andrew.svetlov at gmail.com>
date: 2022-01-22T13:06:27+02:00
summary:

bpo-46425: fix direct invocation of `asyncio` tests (#30725)

files:
M Lib/test/test_asyncio/test_context.py
M Lib/test/test_asyncio/test_futures2.py
M Lib/test/test_asyncio/test_protocols.py
M Lib/test/test_asyncio/test_runners.py
M Lib/test/test_asyncio/test_sendfile.py
M Lib/test/test_asyncio/test_sock_lowlevel.py

diff --git a/Lib/test/test_asyncio/test_context.py b/Lib/test/test_asyncio/test_context.py
index 63b1eb320ce16b..6b80721873d95c 100644
--- a/Lib/test/test_asyncio/test_context.py
+++ b/Lib/test/test_asyncio/test_context.py
@@ -32,3 +32,7 @@ async def main():
 
         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 13dbc703277c81..57d24190bc0bd5 100644
--- a/Lib/test/test_asyncio/test_futures2.py
+++ b/Lib/test/test_asyncio/test_futures2.py
@@ -16,3 +16,7 @@ async def func():
         # 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 438111cccd3478..d8cde6d89aadcd 100644
--- a/Lib/test/test_asyncio/test_protocols.py
+++ b/Lib/test/test_asyncio/test_protocols.py
@@ -55,3 +55,7 @@ def test_subprocess_protocol(self):
         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 b9ae02dc3c04e0..5c06a1aaa830fa 100644
--- a/Lib/test/test_asyncio/test_runners.py
+++ b/Lib/test/test_asyncio/test_runners.py
@@ -2,7 +2,7 @@
 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 @@ async def main():
 
         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 0a5466a0af152b..57b56bba34100b 100644
--- a/Lib/test/test_asyncio/test_sendfile.py
+++ b/Lib/test/test_asyncio/test_sendfile.py
@@ -565,3 +565,7 @@ class SelectEventLoopTests(SendfileTestsBase,
 
         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 ab022a357d205e..448d835b04d570 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 @@ class SelectEventLoopTests(BaseSockTestsMixin,
 
         def create_event_loop(self):
             return asyncio.SelectorEventLoop(selectors.SelectSelector())
+
+
+if __name__ == '__main__':
+    unittest.main()



More information about the Python-checkins mailing list