Skip to content

Commit 6e48794

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

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

tests/test_base.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,26 @@ 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(
805+
"thread_name_prefix was added in CPython 3.9"
806+
)
807+
808+
called = []
809+
810+
def cb():
811+
called.append(threading.current_thread().name)
812+
813+
async def runner():
814+
await self.loop.run_in_executor(None, cb)
815+
816+
self.loop.run_until_complete(runner())
817+
818+
self.assertEqual(len(called), 1)
819+
self.assertTrue(called[0] is not None)
820+
self.assertTrue(called[0].startswith(self.implementation))
821+
802822

803823
class TestBaseUV(_TestBase, UVTestCase):
804824

@@ -938,21 +958,6 @@ def test_loop_call_later_handle_when_after_fired(self):
938958
self.loop.run_until_complete(fut)
939959
self.assertEqual(handle.when(), when)
940960

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-
956961

957962
class TestBaseAIO(_TestBase, AIOTestCase):
958963
pass

0 commit comments

Comments
 (0)