pythonintermediate

Mock Testing

Advanced Python pattern: mock-testing

python
from unittest.mock import Mock

def notify(send, msg: str) -> None:
    send(msg)

send = Mock()
notify(send, 'hello')
send.assert_called_once_with('hello')
print('ok')

Use Cases

  • advanced programming
  • patterns

Tags

Related Snippets

Similar patterns you can reuse in the same workflow.