Skip to content

Commit

Permalink
Add mpl-baseline-path ini option
Browse files Browse the repository at this point in the history
  • Loading branch information
ConorMacBride committed May 20, 2023
1 parent 718308a commit 232f479
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ Directory containing baseline images
------------------------------------
| **kwarg**: ``baseline_dir=<path>``
| **CLI**: ``--mpl-baseline-path=<path>``
| **INI**: ---
| **INI**: ``mpl-baseline-path``
| Default: ``baseline/`` *(relative to the test file)*
The directory containing the baseline images that will be compared to the test figures.
The kwarg option (``baseline_dir``) is relative to the test file, while the CLI option (``--mpl-baseline-path``) is relative to where pytest was run.
The kwarg option (``baseline_dir``) is relative to the test file, while the CLI option (``--mpl-baseline-path``) and INI option (``mpl-baseline-path``) are relative to where pytest was run.
Absolute paths can also be used.
If the directory does not exist, it will be created along with any missing parent directories.

Expand Down
18 changes: 12 additions & 6 deletions pytest_mpl/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,16 @@ def pytest_addoption(parser):
group.addoption('--mpl-generate-hash-library',
help="filepath to save a generated hash library, relative "
"to location where py.test is run", action='store')
group.addoption('--mpl-baseline-path',
help="directory containing baseline images, relative to "
"location where py.test is run unless --mpl-baseline-relative is given. "
"This can also be a URL or a set of comma-separated URLs (in case "
"mirrors are specified)", action='store')

baseline_path_help = (
"directory containing baseline images, relative to "
"location where py.test is run unless --mpl-baseline-relative is given. "
"This can also be a URL or a set of comma-separated URLs (in case "
"mirrors are specified)"
)
group.addoption("--mpl-baseline-path", help=baseline_path_help, action="store")
parser.addini("mpl-baseline-path", help=baseline_path_help)

group.addoption("--mpl-baseline-relative", help="interpret the baseline directory as "
"relative to the test location.", action="store_true")
group.addoption('--mpl-hash-library',
Expand Down Expand Up @@ -181,7 +186,8 @@ def pytest_configure(config):
config.getoption("--mpl-generate-path") is not None or
config.getoption("--mpl-generate-hash-library") is not None):

baseline_dir = config.getoption("--mpl-baseline-path")
baseline_dir = (config.getoption("--mpl-baseline-path") or
config.getini("mpl-baseline-path"))
generate_dir = config.getoption("--mpl-generate-path")
generate_hash_lib = config.getoption("--mpl-generate-hash-library")
results_dir = config.getoption("--mpl-results-path") or config.getini("mpl-results-path")
Expand Down

0 comments on commit 232f479

Please sign in to comment.