asynctest icon indicating copy to clipboard operation
asynctest copied to clipboard

Tutorial: usage with pytest

Open dimaqq opened this issue 5 years ago • 2 comments

It's awesome to have a tutorial!

At the same time, I feel that unittest framework's time has passed (not everyone agrees, it's just my opinion) and we're happily using pytest and it integrates nicely with asynctest.

Our use in a nutshell:

pytestmark = [pytest.mark.asyncio]

@asynctest.mock.patch("some.thing.patched", autospec=True)
async def test_something_or_other(patched, fixture, fixture):
    ...

dimaqq avatar Jun 24 '19 02:06 dimaqq

Hi,

What are you suggesting? Do you think that the examples in the tutorial should use pytest instead of unittest or both?

I use the unittest in the tutorial runner for these reasons:

  • I don't really have an experience with pytest (the unittest runner has always been sufficient for my use cases),
  • asynctest extends unittest.TestCase, while IIRC, pytest suggests a different approach to write test functions (with a decorator),
  • I like that the tutorial don't require to install an external package.

Feedbacks and suggestions are welcome!

Martiusweb avatar Jun 24 '19 11:06 Martiusweb

I, personally, would rather see pytest examples instead of unittest.

At the same time, I'd gladly see pytest examples in addition to unittest when the alternative is only unittest :)

Another possibility is to keep basic examples concise without reference to a specific framework, e.g. https://hypothesis.readthedocs.io/en/latest/quickstart.html

dimaqq avatar Jun 25 '19 06:06 dimaqq