What Is pytest?

A robust Python testing tool, pytest can be used for all types and levels of software testing. pytest can be used by development teams, QA teams, independent testing groups, individuals practicing TDD, and open source projects. In fact, projects all over the Internet have switched from unittest or nose to pytest, including Mozilla and Dropbox. Why? Because pytest offers powerful features such as ‘assert‘ rewriting, a third-party plugin model, and a powerful yet simple fixture model that is unmatched in any other testing framework.

pytest is a software test framework, which means pytest is a command-line tool that automatically finds tests you’ve written, runs the tests, and reports the results. It has a library of goodies that you can use in your tests to help you test more effectively. It can be extended by writing plugins or installing third-party plugins. It can be used to test Python distributions. And it integrates easily with other tools like continuous integration and web automation.

Here are a few of the reasons pytest stands out above many other test frameworks:

  • Simple tests are simple to write in pytest.

  • Complex tests are still simple to write.

  • Tests are easy to read.

  • Tests are easy to read. (So important it’s listed twice.)

  • You can get started in seconds.

  • You use assert to fail a test, not things like self.assertEqual() or self.assertLessThan(). Just assert.

  • You can use pytest to run tests written for unittest or nose.

pytest is being actively developed and maintained by a passionate and growing community. It’s so extensible and flexible that it will easily fit into your work flow. And because it’s installed separately from your Python version, you can use the same latest version of pytest on legacy Python 2 (2.6 and above) and Python 3 (3.3 and above).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.85.221