2026-01-30 14:33 UTC
```python
with patch("some_file.requests.get", side_effect=SomeException("oh no")):
result = func_using_requests()
```
Though not every language makes mocking as easy, and multiple responsibilities in a single function can quickly get messy.
Replies (2)
-
@Tamo240@programming.dev 2026-01-30 16:50
Oh I'm fully aware that python lets you cheat dependency injection with patch, its one of the many things python teaches developers to do wrong, which leads them to be unable to use any other language.
-
@wpb@lemmy.world 2026-01-31 08:58
Quickest way to get a test suite so tightly coupled to structure rather than behavior that even just looking at the tests wrong makes them fail. But technically you do get test coverage I guess. Goodhart's law in action.