Five reasons to use Py.test

Pytest library provides a better way to write tests, run the tests, and report the test results. This post is a comparison between the Python unit test standard library and pytest features and leaves out other libraries like nose2. TL;DR Single assert statement(assert a == b) over 40 different assert methods(self.assertEqual, self.assertIsInstance, self.assertDictEqual) Better and detailed error messages on failure. Useful command line options for reporting, discovering, and reporting tests like --last-failed, --collect-only. [Read More]

Parameterize Python Tests

Introduction A single test case follows a pattern. Setup the data, invoke the function or method with the arguments and assert the return data or the state changes. A function will have a minimum of one or more test cases for various success and failure cases. Here is an example implementation of wc command for a single file that returns number of words, lines, and characters for an ASCII text file. [Read More]