as concrete exampleimagine writing code that uses an object-relational mapper to store object properties in database it is common to use an automatically assigned database id in such objects our code might use this id for various purposes if we are writing test for such codebefore we write itwe may realize that our design is faulty because objects do not have these ids until they have been saved to the database if we want to manipulate an object without saving it in our testit will highlight this problem before we have written code based on the faulty premise testing makes software better writing tests before we release the software makes it better before the end user sees or purchases the buggy version ( have worked for companies that thrive on the "the users can test itphilosophy it' not healthy business model!writing tests before we write software makes it better the first time it is written unit testing let' start our exploration with python' built-in test library this library provides common interface for unit tests unit tests focus on testing the least amount of code possible in any one test each one tests single unit of the total amount of available code the python library for this is calledunsurprisinglyunittest it provides several tools for creating and running unit teststhe most important being the testcase class this class provides set of methods that allow us to compare valuesset up testsand clean up when they have finished when we want to write set of unit tests for specific taskwe create subclass of testcaseand write individual methods to do the actual testing these methods must all start with the name test when this convention is followedthe tests automatically run as part of the test process normallythe tests set some values on an object and then run methodand use the built-in comparison methods to ensure that the right results were calculated here' very simple exampleimport unittest class checknumbers(unittest testcase)def test_int_float(self)self assertequal( if __name__ ="__main__"unittest main(