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.
- Pytest is known for its simplicity and ease of use, making it a favorite among developers.
- It provides a simple syntax for writing test cases, which makes test code more readable and maintainable.
- Pytest supports a wide range of testing methods and can handle unit tests, functional tests, and integration tests.
- It automatically discovers test files and test functions within the project directory, saving developers from the hassle of managing test suites.
- Pytest offers robust assertion capabilities, allowing developers to perform various checks on the expected and actual output.
- It provides advanced features like fixtures, which help to set up and tear down test dependencies, making testing more efficient.
- Pytest supports parallel test execution, enabling faster test runs by utilizing multiple CPU cores.
- It integrates well with other testing tools and frameworks, such as Selenium for web UI testing and coverage.py for code coverage analysis.
- Pytest generates detailed test reports in various formats, including plain text, JUnit XML, and HTML.
- 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 --stepwisetry on your machineexplain this command
-
pytest:tldr:4544d pytest: Run tests matching or excluding markers.$ pytest -m ${marker_name1 and not marker_name2}try on your machineexplain 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 machineexplain this command
-
pytest:tldr:b5b3b pytest: Run tests with names matching a specific [k]eyword expression.$ pytest -k ${expression}try on your machineexplain this command
-
pytest:tldr:cc519 pytest: Run tests without capturing output.$ pytest --capture=notry on your machineexplain this command
-
pytest:tldr:f67e8 pytest: Exit as soon as a test fails or encounters an error.$ pytest --exitfirsttry on your machineexplain this command