Full pytest documentationΒΆ
Download latest version as PDF
- Installation and Getting Started
- Usage and Invocations
- Calling pytest through
python -m pytest
- Getting help on version, option names, environment variables
- Stopping after the first (or N) failures
- Specifying tests / selecting tests
- Modifying Python traceback printing
- Dropping to PDB (Python Debugger) on failures
- Setting a breakpoint / aka
set_trace()
- Profiling test execution duration
- Creating JUnitXML format files
- Creating resultlog format files
- Sending test report to online pastebin service
- Disabling plugins
- Calling pytest from Python code
- Calling pytest through
- The writing and reporting of assertions in tests
- Pytest API and builtin fixtures
- 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 fixtures
- 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
- Monkeypatching/mocking modules and environments
- Temporary directories and files
- Capturing of the stdout/stderr output
- Asserting Warnings
- Doctest integration for modules and test files
- Marking test functions with attributes
- Skip and xfail: dealing with tests that cannot 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
- Summary
- Parametrizing fixtures and test functions
- Cache: working with cross-testrun state
- Support for unittest.TestCase / Integration of fixtures
- Running tests written for nose
- classic xunit-style setup
- Installing and Using plugins
- Writing plugins
- Writing hook functions
- pytest hook reference
- Reference of objects involved in hooks
- Usages and Examples
- Good Integration Practices
- Basic test configuration
- Setting up bash completion
- Backwards Compatibility Policy
- License
- Contribution getting started
- Talks and Tutorials
- Project examples
- Some Issues and Questions
- Contact channels