Skip to content

Commit 6111d5d

Browse files
bpo-46425: fix direct invocation of asyncio tests (GH-30725) (#30782)
(cherry picked from commit 5a53400) Co-authored-by: Nikita Sobolev <[email protected]> Co-authored-by: Nikita Sobolev <[email protected]>
1 parent 90e2998 commit 6111d5d

File tree

6 files changed

+25
-2
lines changed

6 files changed

+25
-2
lines changed

Lib/test/test_asyncio/test_context.py

+4
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ async def main():
3232

3333
self.assertEqual(str(r2[0]), '0.333333')
3434
self.assertEqual(str(r2[1]), '0.111111')
35+
36+
37+
if __name__ == '__main__':
38+
unittest.main()

Lib/test/test_asyncio/test_futures2.py

+4
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ async def func():
1616
# The check for returned string is not very reliable but
1717
# exact comparison for the whole string is even weaker.
1818
self.assertIn('...', repr(await asyncio.wait_for(func(), timeout=10)))
19+
20+
21+
if __name__ == '__main__':
22+
unittest.main()

Lib/test/test_asyncio/test_protocols.py

+4
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@ def test_subprocess_protocol(self):
5555
self.assertIsNone(sp.pipe_connection_lost(1, f))
5656
self.assertIsNone(sp.process_exited())
5757
self.assertFalse(hasattr(sp, '__dict__'))
58+
59+
60+
if __name__ == '__main__':
61+
unittest.main()

Lib/test/test_asyncio/test_runners.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import unittest
33

44
from unittest import mock
5-
from . import utils as test_utils
5+
from test.test_asyncio import utils as test_utils
66

77

88
class TestPolicy(asyncio.AbstractEventLoopPolicy):
@@ -180,3 +180,7 @@ async def main():
180180

181181
self.assertIsNone(spinner.ag_frame)
182182
self.assertFalse(spinner.ag_running)
183+
184+
185+
if __name__ == '__main__':
186+
unittest.main()

Lib/test/test_asyncio/test_sendfile.py

+4
Original file line numberDiff line numberDiff line change
@@ -565,3 +565,7 @@ class SelectEventLoopTests(SendfileTestsBase,
565565

566566
def create_event_loop(self):
567567
return asyncio.SelectorEventLoop(selectors.SelectSelector())
568+
569+
570+
if __name__ == '__main__':
571+
unittest.main()

Lib/test/test_asyncio/test_sock_lowlevel.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import socket
2-
import time
32
import asyncio
43
import sys
54
import unittest
@@ -512,3 +511,7 @@ class SelectEventLoopTests(BaseSockTestsMixin,
512511

513512
def create_event_loop(self):
514513
return asyncio.SelectorEventLoop(selectors.SelectSelector())
514+
515+
516+
if __name__ == '__main__':
517+
unittest.main()

0 commit comments

Comments
 (0)