testing with py test the python unittest module requires lot of boilerplate code to set up and initialize tests it is based on the very popular junit testing framework for java it even uses the same method names (you may have noticed they don' conform to the pep- naming standardwhich suggests underscores rather than camelcase to separate words in method nameand test layout while this is effective for testing in javait' not necessarily the best design for python testing because python programmers like their code to be elegant and simpleother test frameworks have been developedoutside the standard library two of the more popular ones are py test and nose the former is more robust and has had python support for much longerso we'll discuss it here since py test is not part of the standard libraryyou'll need to download and install it yourselfyou can get it from the py test home page at website has comprehensive installation instructions for variety of interpreters and platformsbut you can usually get away with the more common python package installerpip just type pip install pytest on your command line and you'll be good to go py test has substantially different layout from the unittest module it doesn' require test cases to be classes insteadit takes advantage of the fact that python functions are objectsand allows any properly named function to behave like test rather than providing bunch of custom methods for asserting equalityit uses the assert statement to verify results this makes tests more readable and maintainable when we run py testit will start in the current folder and search for any modules in that folder or subpackages whose names start with the characters test_ if any functions in this module also start with testthey will be executed as individual tests furthermoreif there are any classes in the module whose name starts with testany methods on that class that start with test_ will also be executed in the test environment let' port the simplest possible unittest example we wrote earlier to py testdef test_int_float()assert = for the exact same testwe've written two lines of more readable codein comparison to the six lines required in our first unittest example