Skip to content

Commit e12d5d0

Browse files
committed
Move the test to cover asyncio too
1 parent 067febe commit e12d5d0

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

tests/test_base.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,24 @@ async def main():
799799
elif result.returncode != 0:
800800
self.fail(result.stdout.strip())
801801

802+
def test_thread_name_prefix_in_default_executor(self):
803+
if self.implementation == "asyncio" and sys.version_info < (3, 9):
804+
raise unittest.SkipTest("thread_name_prefix was added in CPython 3.9")
805+
806+
called = []
807+
808+
def cb():
809+
called.append(threading.current_thread().name)
810+
811+
async def runner():
812+
await self.loop.run_in_executor(None, cb)
813+
814+
self.loop.run_until_complete(runner())
815+
816+
self.assertEqual(len(called), 1)
817+
self.assertTrue(called[0] is not None)
818+
self.assertTrue(called[0].startswith(self.implementation))
819+
802820

803821
class TestBaseUV(_TestBase, UVTestCase):
804822

@@ -938,21 +956,6 @@ def test_loop_call_later_handle_when_after_fired(self):
938956
self.loop.run_until_complete(fut)
939957
self.assertEqual(handle.when(), when)
940958

941-
def test_thread_name_prefix_in_default_executor(self):
942-
called = []
943-
944-
def cb():
945-
called.append(threading.current_thread().name)
946-
947-
async def runner():
948-
await self.loop.run_in_executor(None, cb)
949-
950-
self.loop.run_until_complete(runner())
951-
952-
self.assertEqual(len(called), 1)
953-
self.assertTrue(called[0] is not None)
954-
self.assertTrue(called[0].startswith("uvloop"))
955-
956959

957960
class TestBaseAIO(_TestBase, AIOTestCase):
958961
pass

0 commit comments

Comments
 (0)