GithubHelp home page GithubHelp logo

Comments (6)

david-caro avatar david-caro commented on April 30, 2024

Hi @fornellas, I have a question about this, in order to support asyncio, the whole module would have to drop python2 support right?

from testslide.

fornellas avatar fornellas commented on April 30, 2024

I suppose you're correct. Python 2 is dying anyway, it's support can be dropped at this point.

from testslide.

fornellas avatar fornellas commented on April 30, 2024

PS: I created a milestone for async stuff https://github.com/facebookincubator/TestSlide/milestone/1, as there's more stuff to implement.

from testslide.

fornellas avatar fornellas commented on April 30, 2024

@fried, what do you think about the approach of using inspect.iscoroutinefunction to detect if the callable (module function, instance/class/static method) is async, and keep the self.mock_callable( interface? The other option would be to have self.mock_async_callable(. I understand that inspect has its limitations, I'm not experience with async to judge if this might lead to users shooting themselves in the foot in those cases.

from testslide.

jivid avatar jivid commented on April 30, 2024

I've put up #60 to provide mock_async_callable. I do believe having an explicit mock_async_callable is better than having the mock_callable interface detect whether it's received a coroutine or a regular function. The latter just feels like it would hide too much from the users.

from testslide.

fried avatar fried commented on April 30, 2024

unittest.IsolatedAsyncioTestCase in 3.8 uses that. So to have async test methods they have to explicitly be coroutines. No sync methods that return awaitables, since that's pretty hairy.
Also the AsyncMock in 3.8 is also a really good interface for async mocks, in that it looks at the spec and if its a coroutine the mocks that return when that is called is another AsyncMock, otherwise you get a normal MagicMock.

from testslide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.