• jjjalljs@ttrpg.network
      link
      fedilink
      arrow-up
      7
      ·
      4 hours ago
      
      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.

      • Tamo240@programming.dev
        link
        fedilink
        arrow-up
        4
        ·
        2 hours ago

        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.