Command-Line Options
In addition the command-line options for used to specify configuration
values described in the previous chapter,
maelstrom-pytest supports these command-line options:
| Option | Short Alias | Argument | Description |
|---|---|---|---|
--help | -h | print help and exit | |
--version | print version and exit | ||
--print-config | -P | print all configuration values and exit | |
--config-file | -c | path or - | file to read configuration values from |
--include | -i | pattern | include tests that match pattern |
--exclude | -x | pattern | exclude tests that match pattern |
--init | initialize test metadata file | ||
--watch | -w | loop running tests then waiting for changes | |
--list | -l | only list matching tests instead of running them |
--include and --exclude
The --include (-i) and --exclude (-x) command-line options control which tests
maelstrom-pytest runs or lists.
These options take a test filter pattern. The --include option
includes any test that matches the pattern. Similarly, --exclude pattern
excludes any test that matches the pattern. Both options are allowed to be
repeated arbitrarily.
The tests that are selected are the set which match any --include pattern but
don’t match any --exclude pattern. In other words, --excludes have precedence
over --includes, regardless of the order they are specified.
If no --include option is provided, maelstrom-pytest acts as if an
--include all option was provided.
--init
The --init command-line option is used to create a starter
maelstrom-pytest.toml file. See here for more
information.
--watch
The --watch command-line option causes maelstrom-pytest to run tests
repeatedly in a loop, waiting for changes to the project directory in between
runs. See here for more information.
--list
The --list command-line option causes maelstrom-pytest
to print the tests that would normally
be run, without actually running them.
This option can be combined with --include and --exclude.
Abbreviations
As discussed here, unambiguous prefixes can be used
in patterns. This can come in handy when doing one-offs on the command line.
For example, to run all tests in package foo with the marker mark:
maelstrom-pytest -i 'p.eq(foo) & m.c(mark)'