mocking for testing it may now be necessary to verify data updates made to the databaseor information sent to remote service etc to confirm that the operation of class' object is correct this makes not only the software being tested more complex but it also makes the tests themselves more complex this means that there is greater chance that the test will failthat the tests will contain bugs or issues themselves and that the test will be harder for someone to understand and maintain thus common objective when writing unit tests or subsystem tests is to be able to test elementsunits in isolation the question is how to do this when function or method relies on other elementsthe key to decoupling functionsmethods and objects from other program or system elements is to use mocks these mocks can be used to decouple one object rom anotherone function from another and one system from anotherthereby simplifying the testing environment these mocks are only intended to be used for testing purposesfor example the above scenario could be simplified by mocking out each of the external systems as shown belowmocking is not python specific concept and there are many mocking libraries available for may different languages howeverin this we will be focussing on the unites mock library which has been part of the standard python distribution since python why mocka useful first question to consider with regard to mockingin software testingis 'why mock?that iswhy bother with the concept of mock in the first placewhy not test with the real thingthere are several answers to thissome of which are discussed below