
Usages and Examples
*******************

Here is a (growing) list of examples. *Contact* us if you need more
examples or have questions. Also take a look at the *comprehensive
documentation* which contains many example snippets as well.  Also,
pytest on stackoverflow.com often comes with example answers.

For basic examples, see

* *Installation and Getting Started* for basic introductory examples

* *Asserting with the assert statement* for basic assertion examples

* *pytest fixtures: explicit, modular, scalable* for basic
  fixture/setup examples

* *Parametrizing fixtures and test functions* for basic test function
  parametrization

* *Support for unittest.TestCase / Integration of fixtures* for basic
  unittest integration

* *Running tests written for nose* for basic nosetests integration

The following examples aim at various use cases you might encounter.

* Demo of Python failure reports with py.test
* Basic patterns and examples
  * Pass different values to a test function, depending on command
    line options
  * Dynamically adding command line options
  * Control skipping of tests according to command line option
  * Writing well integrated assertion helpers
  * Detect if running from within a py.test run
  * Adding info to test report header
  * profiling test duration
  * incremental testing - test steps
  * Package/Directory-level fixtures (setups)
  * post-process test reports / failures
  * Making test result information available in fixtures
* Parametrizing tests
  * Generating parameters combinations, depending on command line
  * A quick port of "testscenarios"
  * Deferring the setup of parametrized resources
  * Parametrizing test methods through per-class configuration
  * Indirect parametrization with multiple fixtures
  * Indirect parametrization of optional implementations/imports
* Working with custom markers
  * Marking test functions and selecting them for a run
  * Using "-k expr" to select tests based on their name
  * Registering markers
  * Marking whole classes or modules
  * Custom marker and command line option to control test runs
  * Reading markers which were set from multiple places
  * marking platform specific tests with pytest
  * Automatically adding markers based on test names
* A sesssion-fixture which can look at all collected tests
* Changing standard (Python) test discovery
  * Changing directory recursion
  * Changing naming conventions
  * Interpreting cmdline arguments as Python packages
  * Finding out what is collected
  * customizing test collection to find all .py files
* Working with non-python tests
  * A basic example for specifying tests in Yaml files