![Forrest logo](/images/logo.png)
pytest:tldr:b5b3b
The command "pytest -k ${expression}" is used to run pytest tests that match a specific expression.
Here is what each part of the command means:
- "pytest": It is the command to invoke pytest, which is a testing framework for Python.
- "-k": It stands for "keyword expression" and is used to filter and select specific tests based on the given expression.
- "${expression}": It is the placeholder for the specific expression you want to use to filter the tests. You need to replace "${expression}" with your desired expression.
The expression can be a substring that matches part of a test name, enabling selective execution of specific tests. For example, if you have test functions named "test_addition", "test_subtraction", and "test_multiplication", and you want to run only the tests related to addition, you can use the expression "addition" to filter and execute only those tests.
Here's an example command usage:
pytest -k addition
This command will run all the tests that have "addition" in their name.
You can also use regular expressions as expressions to have more flexibility in selecting tests. You can get detailed information on how to use expressions and other command options in the pytest documentation.