Pytest: customize test discovery through command line

Viewed 76

There are ways to configure pytest test discovery through configuration file .

I wonder if there are ways to configure pytest test discovery through command line options/args. In other words, can I just pass some argument/switch to pytest command to achieve this?

1 Answers

Every entry you put in the config file (so-called "inioption") can be passed from command line using the -o/--override-ini option. The -o option can be applied multiple times. E.g.

$ pytest -o python_files='check_*.py' \
         -o python_classes=Check \
         -o python_functions='*_check'

Source: Configuration Options.

Related