Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ideas for asyncio #170

Open
rwols opened this issue Dec 29, 2019 · 1 comment
Open

Ideas for asyncio #170

rwols opened this issue Dec 29, 2019 · 1 comment

Comments

@rwols
Copy link
Contributor

rwols commented Dec 29, 2019

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

@randy3k
Copy link
Member

randy3k commented Dec 30, 2019

it seems that we could borrow some idea from https://github.com/kwarunek/aiounittest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants