Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing specific tests using pytest

Tags:

python

pytest

Is there a way in pytest to add an attribute to a test, say for example "smoke test" or "regression" and then run only those tests?

like image 691
bfan Avatar asked Feb 19 '26 01:02

bfan


1 Answers

Yes, you can use Markers for that.

See "Marking test functions and selecting them for a run"

Essentially, you will "mark" some of your tests with @pytest.mark.smoke and then launch them with a command like $ pytest -m smoke.

like image 131
Laurent Bristiel Avatar answered Feb 20 '26 14:02

Laurent Bristiel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!