Add support for async test coroutines#292
Conversation
rwols
left a comment
There was a problem hiding this comment.
This will definitely help. I have a custom hacky test case defined here for now: https://github.com/sublimelsp/LSP/pull/2880/changes#diff-71bab432ef1fd86da70970d919de9bcb94824da23dfce20552da20342a30d8da
I haven't read the full diff here, but please make sure the following (class)methods can also be async:
@classmethod
async def setUpClass(cls) -> None:
pass
@classmethod
async def tearDownClass(cls) -> None:
pass
async def doCleanups(self) -> None:
pass|
One more suggestion: instead of hardcoding the dependency on sublime_aio, perhaps allow supplying a function for starting a coroutine using dependency injection. |
|
Note, That being said, this PR takes pretty much the same approach by extending |
This PR adds
AsyncTestCaseandAsyncViewTestCasefor testing asyncio coroutines, which interact with Sublime Text.Both classes work pretty much like
DeferrableTestCase, except they canawaitcoroutines.Initial implementation inherits
AsyncTestCasefromDeferrableTestCaseto explicitly provide a new API with async coroutine support. Each coroutine function is scheduled for execution insublime_aio's default event loop. Underlying test method awaits completion viayield future.doneto enable coroutines to run synchronous tasks in main thread viasublime.set_timeout().Yielding from async coroutines is not supported.
@rwols: May help with asyncio testing in LSP.