Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using -p no:legacypath with pytest >= 7 #213

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pytest_mpl/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from urllib.request import urlopen

import pytest
from packaging.version import Version

from pytest_mpl.summary.html import generate_summary_basic_html, generate_summary_html

Expand All @@ -56,6 +57,8 @@
Actual shape: {actual_shape}
{actual_path}"""

PYTEST_LT_7 = Version(pytest.__version__) < Version("7.0.0")

# The following are the subsets of formats supported by the Matplotlib image
# comparison machinery
RASTER_IMAGE_FORMATS = ['png']
Expand All @@ -64,8 +67,8 @@


def _get_item_dir(item):
# .path is available starting from pytest 7, .fspath is for older versions.
return getattr(item, "path", Path(item.fspath)).parent
path = Path(item.fspath) if PYTEST_LT_7 else item.path
return path.parent


def _hash_file(in_stream):
Expand Down
Loading