1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
import pytest
from helpers import pytester_path
@pytest.mark.parametrize(
"ini, cli, expected",
[
("dir1", None, "dir1"),
("dir1", "dir2", "dir2"),
(None, "dir2", "dir2"),
],
)
def test_config(pytester, ini, cli, expected):
ini = f"mpl-results-path = {ini}" if ini else ""
pytester.makeini(
f"""
[pytest]
{ini}
"""
)
pytester.makepyfile(
"""
import matplotlib.pyplot as plt
import pytest
@pytest.mark.mpl_image_compare
def test_mpl():
fig, ax = plt.subplots()
ax.plot([1, 2, 3])
return fig
"""
)
cli = f"--mpl-results-path={cli}" if cli else ""
result = pytester.runpytest("--mpl", cli)
result.assert_outcomes(failed=1)
assert (pytester_path(pytester) / expected / "test_config.test_mpl" / "result.png").exists()
|