What if you never had to type your test options again and still get perfect results every time?
Why Addopts for default options in PyTest? - Purpose & Use Cases
Imagine running your tests every day by typing long commands with many options manually in the terminal.
You have to remember each option and type it exactly right every time.
This manual way is slow and easy to forget options.
Sometimes you miss important flags, causing tests to run differently or miss important checks.
It wastes time and causes confusion among team members.
Using addopts in pytest's configuration file sets default options automatically.
You just run pytest and all your preferred options are applied every time without typing them.
pytest -v --maxfail=2 --capture=no[pytest]
addopts = -v --maxfail=2 --capture=noYou can run tests quickly and consistently with your favorite options always applied, saving time and avoiding mistakes.
A developer runs tests daily and wants to always see detailed output and stop after 2 failures.
With addopts, they never have to remember these options again.
Typing test options manually is slow and error-prone.
addopts sets default options in pytest config for easy reuse.
This makes test runs faster, consistent, and less frustrating.