Forrest logo
tool overview
On this page you find all important commands for the CLI tool pytest. If the command you are looking for is missing please ask our AI.

pytest

Pytest is a command-line tool that is used for running automated tests written in Python. It is a popular and widely used testing framework in the Python ecosystem.

  1. Pytest is known for its simplicity and ease of use, making it a favorite among developers.
  2. It provides a simple syntax for writing test cases, which makes test code more readable and maintainable.
  3. Pytest supports a wide range of testing methods and can handle unit tests, functional tests, and integration tests.
  4. It automatically discovers test files and test functions within the project directory, saving developers from the hassle of managing test suites.
  5. Pytest offers robust assertion capabilities, allowing developers to perform various checks on the expected and actual output.
  6. It provides advanced features like fixtures, which help to set up and tear down test dependencies, making testing more efficient.
  7. Pytest supports parallel test execution, enabling faster test runs by utilizing multiple CPU cores.
  8. It integrates well with other testing tools and frameworks, such as Selenium for web UI testing and coverage.py for code coverage analysis.
  9. Pytest generates detailed test reports in various formats, including plain text, JUnit XML, and HTML.
  10. It has an extensive plugin ecosystem, offering additional features and integrations with other tools, allowing developers to customize their testing workflows.

List of commands for pytest:

  • pytest:tldr:18482 pytest: Run until a test failure, continuing from the last failing test.
    $ pytest --stepwise
    try on your machine
    explain this command
  • pytest:tldr:4544d pytest: Run tests matching or excluding markers.
    $ pytest -m ${marker_name1 and not marker_name2}
    try on your machine
    explain this command
  • pytest:tldr:b528d pytest: Run tests from specific files.
    $ pytest ${path-to-test_file1-py path-to-test_file2-py ---}
    try on your machine
    explain this command
  • pytest:tldr:b5b3b pytest: Run tests with names matching a specific [k]eyword expression.
    $ pytest -k ${expression}
    try on your machine
    explain this command
  • pytest:tldr:cc519 pytest: Run tests without capturing output.
    $ pytest --capture=no
    try on your machine
    explain this command
  • pytest:tldr:f67e8 pytest: Exit as soon as a test fails or encounters an error.
    $ pytest --exitfirst
    try on your machine
    explain this command
tool overview