uber / doubles

Test doubles for Python.
MIT License
165 stars 17 forks source link

Add support for asyncio.Future #146

Open charlax opened 2 years ago

charlax commented 2 years ago

In its current state, doubles's and_return_future only returns concurrent.futures.Future or tornado.concurrent.Future.

def _get_future():
    try:
        from concurrent.futures import Future
    except ImportError:
        try:
            from tornado.concurrent import Future
        except ImportError:
            raise ImportError(
                'Error Importing Future, Could not find concurrent.futures or tornado.concurrent',
            )
    return Future()

To make it work with asyncio, I had to manually patch _get_future:

from asyncio import Future
from typing import Any

import doubles

def fix_doubles_future() -> None:
    def _get_future() -> Future[Any]:
        return Future()

    doubles.allowance._get_future = _get_future

fix_doubles_future()

There should be a way to configure this globally or on a per-call basis.

Btw, I'd be happy to implement the fix but it seems this repository is not maintained anymore: https://github.com/uber/doubles/issues/145

jmaliksi commented 1 year ago

@charlax hi charlax i just ran into this as well, should we fork this repo?

toddsifleet commented 1 year ago

@charlax @jmaliksi I hope all is well!

I was already thinking of forking this because I ran into some other issues (see #148).

I will get a new fork up and published, any thoughts on the name?

charlax commented 1 year ago

Oh hey friends!

For sure, let's fork! doubles is awesome.

jmaliksi commented 1 year ago

doubles....2

toddsifleet commented 10 months ago

@charlax @jmaliksi dobles has been launched. It is just at feature parity now, I'll work on improving all the async stuff this week.

charlax commented 10 months ago

Oooooh nice thanks Todd!

On Sun, Oct 29, 2023 at 4:40 PM Todd Sifleet @.***> wrote:

@charlax https://github.com/charlax @jmaliksi https://github.com/jmaliksi dobles https://github.com/smartfastlabs/dobles has been launched. It is just at feature parity now, I'll work on improving all the async stuff this week.

— Reply to this email directly, view it on GitHub https://github.com/uber/doubles/issues/146#issuecomment-1784219255, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA5NNNWMCB5ZAZM4YPXQALYB25KPAVCNFSM5OEIMLT2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCNZYGQZDCOJSGU2Q . You are receiving this because you were mentioned.Message ID: @.***>