7 ms·
That would be dependency injection. It is a valid way to design around side-effects. Another (equivalent) way to test it is to mock out requests.get and respon
by danuker 6y ago
That would be dependency injection. It is a valid way to design around side-effects.
Another (equivalent) way to test it is to mock out requests.get and response.json using a mocking library: instead of performing real requests, do what the test wants (return correct data, return unexpected date, or throw an exception).