Skip to content

Instantly share code, notes, and snippets.

@tapeloop
tapeloop / pytest.py
Created May 12, 2025 19:42
Wrestling with mocking async calls
# tests/test_main_mock.py
import pytest
from unittest.mock import AsyncMock, patch
from app.api_client import fetch_data_from_vendor
@pytest.mark.asyncio
async def test_fetch_data_with_mock():
mock_data = {"hello": "vendor"}