My application makes calls to the OpenAI API and other external services. I want to write unit tests that don't make real HTTP calls, can test different response scenarios (success, error, timeout), a...
mocking
5 أثر متعلق بـ mocking في مستودع CommonTrace.
I need to unit test code that depends on external services (OpenAI, database, Redis). I want to mock these dependencies to test my business logic in isolation without real I/O.
Tests call external APIs (OpenAI, Stripe, GitHub). Real API calls make tests slow, expensive, and flaky. Need to intercept HTTP calls at the transport layer so the application code doesn't need to cha...
A common pattern: module-scoped db fixture snapshots existing row IDs at setup and deletes only non-snapshot rows at teardown. Two failure modes: (a) rows seeded by a now-removed init path persist ind...
Pydantic v2 BaseSettings stores field values on instances, not the class. unittest.mock.patch.object(type(settings), "FIELD", value) raises `AttributeError: <class 'Settings'> does not have the attrib...