Skip to content

Commit 232f479

Browse files
committed
Add mpl-baseline-path ini option
1 parent 718308a commit 232f479

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

docs/configuration.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ Directory containing baseline images
8484
------------------------------------
8585
| **kwarg**: ``baseline_dir=<path>``
8686
| **CLI**: ``--mpl-baseline-path=<path>``
87-
| **INI**: ---
87+
| **INI**: ``mpl-baseline-path``
8888
| Default: ``baseline/`` *(relative to the test file)*
8989
9090
The directory containing the baseline images that will be compared to the test figures.
91-
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.
91+
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.
9292
Absolute paths can also be used.
9393
If the directory does not exist, it will be created along with any missing parent directories.
9494

pytest_mpl/plugin.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,16 @@ def pytest_addoption(parser):
133133
group.addoption('--mpl-generate-hash-library',
134134
help="filepath to save a generated hash library, relative "
135135
"to location where py.test is run", action='store')
136-
group.addoption('--mpl-baseline-path',
137-
help="directory containing baseline images, relative to "
138-
"location where py.test is run unless --mpl-baseline-relative is given. "
139-
"This can also be a URL or a set of comma-separated URLs (in case "
140-
"mirrors are specified)", action='store')
136+
137+
baseline_path_help = (
138+
"directory containing baseline images, relative to "
139+
"location where py.test is run unless --mpl-baseline-relative is given. "
140+
"This can also be a URL or a set of comma-separated URLs (in case "
141+
"mirrors are specified)"
142+
)
143+
group.addoption("--mpl-baseline-path", help=baseline_path_help, action="store")
144+
parser.addini("mpl-baseline-path", help=baseline_path_help)
145+
141146
group.addoption("--mpl-baseline-relative", help="interpret the baseline directory as "
142147
"relative to the test location.", action="store_true")
143148
group.addoption('--mpl-hash-library',
@@ -181,7 +186,8 @@ def pytest_configure(config):
181186
config.getoption("--mpl-generate-path") is not None or
182187
config.getoption("--mpl-generate-hash-library") is not None):
183188

184-
baseline_dir = config.getoption("--mpl-baseline-path")
189+
baseline_dir = (config.getoption("--mpl-baseline-path") or
190+
config.getini("mpl-baseline-path"))
185191
generate_dir = config.getoption("--mpl-generate-path")
186192
generate_hash_lib = config.getoption("--mpl-generate-hash-library")
187193
results_dir = config.getoption("--mpl-results-path") or config.getini("mpl-results-path")

0 commit comments

Comments
 (0)