pytest - rapid and simple testing with Python

Type:
Talk
Audience level:
Novice
Category:
Testing
March 9th 2:40 p.m. – 3:20 p.m.

Description

The py.test tool presents a rapid and simple way to write tests. This talks introduces common testing terms, basic examples and unique pytest features for writing unit- or functional tests: assertions and dependency injection mechanisms. We also look at other features like distributing test load, new plugins and reasons why some Redhat and Mozilla people choose pytest over other approaches.

Abstract

The py.test tool presents a rapid and simple way to write tests for your Python code. This talks introduces some common testing terminology and basic pytest usage. Moreover, it discusses some unique pytest features for writing unit- or functional tests. For unit tests, the simple Python "assert" statement is used for coding assertions. As of 2011, this assert support has been perfected for Python 2.6 or higher, finally removing what some people have formerly called "magic side effects". For writing functional or acceptance tests py.test features a unique depdendency injection mechanism for managing test resources. The talk shows how to setup these resources and how to configure it via command line options. More recently, QA folks from Mozilla and Redhat QA people have endorsed come to appreciate these unique features and the general customizability. The talk concludes with a look on other features like distributing test load and other recently released plugins.

This is the planned series of topics:

  • unit- and functional testing

  • why pytest and not Python packaged unittest package?

  • simple test example and assertions

  • example of dependency injection

  • example usage from webqa mozilla project

  • mocking and monkeypatching

  • distributed test load to processors

  • non-python test discovery

  • customized reporting

  • outlook on future releases