← 返回首页
Explanation - pytest documentation Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode
Skip to content
pytest documentation
Get Started
How-to guides
How to invoke pytest
How to write and report assertions in tests
How to use fixtures
How to mark test functions with attributes
How to parametrize fixtures and test functions
How to use subtests
How to use temporary directories and files in tests
How to monkeypatch/mock modules and environments
How to run doctests
How to re-run failed tests and maintain state between test runs
How to handle test failures
Managing pytest’s output
How to manage logging
How to capture stdout/stderr output
How to capture warnings
How to use skip and xfail to deal with tests that cannot succeed
How to install and use plugins
Writing plugins
Writing hook functions
How to use pytest with an existing test suite
How to use
unittest
-based tests with pytest
How to implement xunit-style set-up
How to set up bash completion
Reference guides
API Reference
Fixtures reference
Configuration
Exit codes
Pytest Plugin List
Explanation
Anatomy of a test
About fixtures
Good Integration Practices
pytest import mechanisms and
sys.path
/
PYTHONPATH
Typing in pytest
CI Pipelines
Flaky tests
Examples and customization tricks
Demo of Python failure reports with pytest
Basic patterns and examples
Parametrizing tests
Working with custom markers
A session-fixture which can look at all collected tests
Changing standard (Python) test discovery
Working with non-python tests
Using a custom directory collector
About the project
Changelog
Contributing
Backwards Compatibility Policy
History
Python version support
Sponsor
pytest for enterprise
License
Contact channels
Useful links
pytest @ PyPI
pytest @ GitHub
Issue Tracker
PDF Documentation
Back to top
Explanation
¶
Anatomy of a test
About fixtures
Good Integration Practices
pytest import mechanisms and
sys.path
/
PYTHONPATH
Typing in pytest
CI Pipelines
Flaky tests
Next
Anatomy of a test
Previous
Pytest Plugin List
Copyright © 2015, holger krekel and pytest-dev team
Made with
Sphinx
and
@pradyunsg
's
Furo