So let's say I have this bit of code:
import coolObject def doSomething(): x = coolObject() x.coolOperation() Now it's a simple enough method, and as you can see we are using an external library(coolObject). In unit tests, I have to create a mock of this object that roughly replicates it. Let's call this mock object coolMock.
My question is how would I tell the code when to use coolMock or coolObject? I've looked it up online, and a few people have suggested dependency injection, but I'm not sure I understand it correctly.
Thanks in advance!