Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Unittest AsyncMock

Unittest AsyncMock

Talk about how to mock async methods in different versions of Python

5965833d3455df42dbe23fa988ef7da1?s=128

Pranay Suresh

February 05, 2020
Tweet

Transcript

  1. Unittest AsyncMock https://pranaysuresh.com/ https://www.linkedin.com/in/pranaysuresh/

  2. None
  3. None
  4. Because...

  5. Prior to Python 3.8 Option 1: Custom solution

  6. Prior to Python 3.8

  7. Prior to Python 3.8 Option 2: asynctest library: https://pypi.org/project/asynctest/

  8. Python 3.8

  9. None
  10. Other features: assert_awaited, assert_awaited_once, assert_awaited_with, await_count etc etc.

  11. Other features: Mock iterators

  12. Other features: Mock context managers

  13. Thank You!