Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Run pytest in the root directory of your project to run all test suites.
You can run test cases in a specific test file (e.g., test_file.py)
using the command pytest test_file.py.
You can run a specific test (e.g., test_func)
in a test file (e.g., test_func) using pytest test_file.py -k test_func.
you can also pass parameters to a test function using
pytest test_file.py:::test_func[0-0-0-invalid].
pytest import mechanisms and sys.path/PYTHONPATH¶
--tb=short --lf (last failure)
Markers¶
@pytest.mark.foo where foo can be any arbitrary string you like,
e.g., @pytest.mark.slow tells pytest that the marked test takes a long time to run.
http://
http://
https://
Capturing of the stdout/stderr output¶
You can disable all capturing using the -s option
(which is equivalent to --capture=no).
pytest -sFor more details, please refer to Capturing of the stdout/stderr output .
Parameterized Tests¶
Talk: Brian K Okken - Multiply your Testing Effectiveness with Parameterized Testing
Plugins¶
https://
https://
https://
https://
https://
https://
https://
References¶
Changing standard (Python) test discovery¶
Is there a way to specify which pytest tests to run from a file?
https://