pytest.org
pytest
https://pytest.org
Installation and Getting Started
Continue reading¶. Check out additional pytest resources to help you customize tests for your unique workflow: " Calling pytest through python -m pytest " for command line invocation examples " Using pytest with an existing test suite " for working with pre-existing tests " Marking test functions with attributes " for information on the pytest.mark mechanism
Examples and Customization Tricks
Also, pytest on stackoverflow.com often comes with example answers. For basic examples, see. Get Started for basic introductory examples. How to write and report assertions in tests for basic assertion examples. Fixtures for basic fixture/setup examples. How to parametrize fixtures and test functions for basic test function parametrization
Full Pytest Documentation
funcargs and pytest_funcarg__ @pytest.yield_fixture decorator [pytest] header in setup.cfg; Applying marks to @pytest.mark.parametrize parameters; @pytest.mark.parametrize argument names as a tuple; setup: is now an "autouse fixture" Conditions as strings instead of booleans; pytest.set_trace() "compat" properties; Talks and Tutorials ...
Parametrize
pytest enables test parametrization at several levels: pytest.fixture() allows one to parametrize fixture functions. @pytest.mark.parametrize allows one to define multiple sets of arguments and fixtures at the test function or class. pytest_generate_tests allows one to define custom parametrization schemes or extensions.
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
Configuration
Initialization: determining rootdir and configfile¶. pytest determines a rootdir for each test run which depends on the command line arguments (specified test files, paths) and on the existence of configuration files. The determined rootdir and configfile are printed as part of the pytest header during startup.. Here's a summary what pytest uses rootdir for: