Navigation
next
previous
|
pytest-2.7.0
»
pytest reference documentation
ΒΆ
Pytest API and builtin fixtures
Invoking pytest interactively
Helpers for assertions about Exceptions/Warnings
Raising a specific test outcome
fixtures and requests
Builtin fixtures/function arguments
Basic test configuration
Command line options and configuration file settings
initialization: determining rootdir and inifile
How to change command line options defaults
Builtin configuration file options
The writing and reporting of assertions in tests
Asserting with the
assert
statement
Assertions about expected exceptions
Making use of context-sensitive comparisons
Defining your own assertion comparison
Advanced assertion introspection
pytest fixtures: explicit, modular, scalable
Fixtures as Function arguments
“Funcargs” a prime example of dependency injection
Sharing a fixture across tests in a module (or class/session)
fixture finalization / executing teardown code
Fixtures can introspect the requesting test context
Parametrizing a fixture
Modularity: using fixtures from a fixture function
Automatic grouping of tests by fixture instances
using fixtures from classes, modules or projects
autouse fixtures (xUnit setup on steroids)
Shifting (visibility of) fixture functions
Overriding fixtures on various levels
Fixture functions using “yield” / context manager integration
Discussion and future considerations / feedback
Parametrizing fixtures and test functions
@pytest.mark.parametrize
: parametrizing test functions
Basic
pytest_generate_tests
example
The
metafunc
object
classic xunit-style setup
Module level setup/teardown
Class level setup/teardown
Method and function level setup/teardown
Capturing of the stdout/stderr output
Default stdout/stderr/stdin capturing behaviour
Setting capturing methods or disabling capturing
Using print statements for debugging
Accessing captured output from a test function
Monkeypatching/mocking modules and environments
Simple example: monkeypatching functions
example: preventing “requests” from remote operations
example: setting an attribute on some class
Method reference of the monkeypatch function argument
xdist: pytest distributed testing plugin
Installation of xdist plugin
Usage examples
Temporary directories and files
The ‘tmpdir’ test function argument
The default base temporary directory
Marking test functions with attributes
API reference for mark related objects
Skip and xfail: dealing with tests that can not succeed
Marking a test function to be skipped
Skip all test functions of a class or module
Mark a test function as expected to fail
Skip/xfail with parametrize
Imperative xfail from within a test or setup function
Skipping on a missing import dependency
specifying conditions as strings versus booleans
Asserting deprecation and other warnings
The recwarn function argument
Ensuring a function triggers a deprecation warning
Support for unittest.TestCase / Integration of fixtures
Usage
Mixing pytest fixtures into unittest.TestCase style tests
autouse fixtures and accessing other fixtures
Running tests written for nose
Usage
Supported nose Idioms
Unsupported idioms / known issues
Doctest integration for modules and test files
Table Of Contents
Home
Contents
Install
Examples
Customize
Contact
Talks/Posts
Changelog
Related Topics
Documentation overview
Previous:
Some Issues and Questions
Next:
Pytest API and builtin fixtures
Useful Links
The pytest Website
Contribution Guide
pytest @ PyPI
pytest @ Bitbucket
3rd party plugins
Issue Tracker
PDF Documentation
Quick search
Enter search terms or a module, class or function name.