requests.get inside functions makes them untestable offline. Write class WeatherClient whose constructor accepts a getter callable (defaulting to requests.get); temperature(city) calls self.getter(...) with the city as a param and returns json()['temp']. Tests can now inject a fake getter.WeatherClient(fake_get).temperature('Pune')the temp from the injected fake, no network
The dependency is swappable — that is the whole point.
Store the callable on self.
The default argument wires production behavior.