Skip to content

Ideas for asyncio #170

@rwols

Description

@rwols

I'm planning to rely completely on asyncio for ST4 and LSP, and I want to be able to run tests with asyncio.

I'm envisioning this possibility:

from my_package import get_my_custom_loop
from unittesting import AsyncTestCase
import asyncio


class MyTestSuite(AsyncTestCase):

    # customization point: allow the user to define its own loop
    # if this function is not overridden, UnitTesting should provide its own loop
    def get_running_loop(self) -> asyncio.AbstractEventLoop:
        return get_my_custom_loop()

    # customization point: are the tests in this suite allowed to run all at once or one after the other?
    def allowed_to_run_parallel(self) -> bool:
        return False

    # customization point if get_running_loop is overridden: we want to know if the loop is running on the UI thread
    # or not
    def loop_is_on_main_thread(self) -> bool:
        return False

    # an actual test
    async def test_foo(self) -> None:
        await asyncio.sleep(1)
        self.assertTrue(True)

See also: sublimehq/sublime_text#3129

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions