extended xUnit style setup

Note:

Since version 1.0 funcargs present the new and more powerful way to manage test setups with larger test suites. funcargs also provide flexible test parametrization which goes way beyond what you can do with the xUnit setup/teardown-method patter.

Python, Java and many other languages have a tradition of using xUnit style testing. This typically involves the call of a setup method before a test function is run and teardown after it finishes. With py.test there are three scopes for which you can provide setup/teardown hooks to provide test fixtures: per-module, per-class and per-method/function. py.test will discover and call according methods automatically.

The unittest plugin also will intregate unittest.TestCase instances into a test run and call respective setup/teardown methods.

All setup/teardown methods are optional.

The following methods are called at module level if they exist:

The following hooks are available for test classes:

The last two hooks, setup_method and teardown_method, are equivalent to setUp and tearDown in the Python standard library's unittest.py module.

Note that it possible that setup/teardown pairs are invoked multiple times per testing process.