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

(cherry picked from commit 5a5340044c)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
Miss Islington (bot) 2022-01-22 04:29:51 -08:00 committed by GitHub
parent 90e2998db7
commit 6111d5dee2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 2 deletions

View file

@ -32,3 +32,7 @@ async def main():
self.assertEqual(str(r2[0]), '0.333333') self.assertEqual(str(r2[0]), '0.333333')
self.assertEqual(str(r2[1]), '0.111111') self.assertEqual(str(r2[1]), '0.111111')
if __name__ == '__main__':
unittest.main()

View file

@ -16,3 +16,7 @@ async def func():
# The check for returned string is not very reliable but # The check for returned string is not very reliable but
# exact comparison for the whole string is even weaker. # exact comparison for the whole string is even weaker.
self.assertIn('...', repr(await asyncio.wait_for(func(), timeout=10))) self.assertIn('...', repr(await asyncio.wait_for(func(), timeout=10)))
if __name__ == '__main__':
unittest.main()

View file

@ -55,3 +55,7 @@ def test_subprocess_protocol(self):
self.assertIsNone(sp.pipe_connection_lost(1, f)) self.assertIsNone(sp.pipe_connection_lost(1, f))
self.assertIsNone(sp.process_exited()) self.assertIsNone(sp.process_exited())
self.assertFalse(hasattr(sp, '__dict__')) self.assertFalse(hasattr(sp, '__dict__'))
if __name__ == '__main__':
unittest.main()

View file

@ -2,7 +2,7 @@
import unittest import unittest
from unittest import mock from unittest import mock
from . import utils as test_utils from test.test_asyncio import utils as test_utils
class TestPolicy(asyncio.AbstractEventLoopPolicy): class TestPolicy(asyncio.AbstractEventLoopPolicy):
@ -180,3 +180,7 @@ async def main():
self.assertIsNone(spinner.ag_frame) self.assertIsNone(spinner.ag_frame)
self.assertFalse(spinner.ag_running) self.assertFalse(spinner.ag_running)
if __name__ == '__main__':
unittest.main()

View file

@ -565,3 +565,7 @@ class SelectEventLoopTests(SendfileTestsBase,
def create_event_loop(self): def create_event_loop(self):
return asyncio.SelectorEventLoop(selectors.SelectSelector()) return asyncio.SelectorEventLoop(selectors.SelectSelector())
if __name__ == '__main__':
unittest.main()

View file

@ -1,5 +1,4 @@
import socket import socket
import time
import asyncio import asyncio
import sys import sys
import unittest import unittest
@ -512,3 +511,7 @@ class SelectEventLoopTests(BaseSockTestsMixin,
def create_event_loop(self): def create_event_loop(self):
return asyncio.SelectorEventLoop(selectors.SelectSelector()) return asyncio.SelectorEventLoop(selectors.SelectSelector())
if __name__ == '__main__':
unittest.main()