You’ve used a lot of command-line options for pytest so far, like -v/--verbose for verbose output and -l/--showlocals to see local variables with the stack trace for failed tests. You may find yourself always using some of those options—or preferring to use them—for a project. If you set addopts in pytest.ini to the options you want, you don’t have to type them in anymore. Here’s a set I like:
| [pytest] |
| addopts = -rsxX -l --tb=short --strict |
The -rsxX tells pytest to report the reasons for all tests that skipped, xfailed, or xpassed. The -l tells pytest to report the local variables for every failure with the stacktrace. The --tb=short removes a lot of the stack trace. It leaves the file and line number, though. The --strict option disallows markers to be used if they aren’t registered in a config file. You’ll see how to do that in the next section.
3.22.41.212