Problem Statement
In pytest, what is a good way to isolate external services during unit tests?
Explanation
Unit tests should be fast and deterministic. Replace outbound calls with fakes or fixtures so tests do not depend on the network.
Keep a separate suite for integration tests against real services.
Code Solution
SolutionRead Only
def test_client(monkeypatch):
monkeypatch.setattr('client.http_get', lambda url: {'ok':True})
assert my_call()==True