News for hackers. Stuff that matters.
Re:Why a mock doesn’t work by coldtea on Sunday August 04, 2019 @02:20PM (#20608285)
>Sure but then I have to write my real library code using an abstraction, making my code more difficult to read and maintain

Or easier - as the abstraction can simplify the interface, localize the logic for directory work, make it easier to port, and so on. That's the reason why most of us use "requests" and not urllib, too, for example, or Yoda and not Java's legacy time mess.

>a dependency injection system is then necessary in order to have the correct concrete implementations set up at runtime.

You can write alterative implementations (whether with base class, interface, traits, or what have you) and use them for production code and for testing without any dependency injection.

>Those of us using Python are using it because it is an interpreted, dynamic scripting language.

The abstractions mentioned come from Smalltalk, which arguably is the same or even more dynamic than Python. Having a class/interface/protocol/trait and a test implementation is by no means a static typing/Java thing, or counter to a dynamic language, as implied here...

There are no comments on this comment yet.