Skip to content

Commit f27a86e

Browse files
Merge pull request #213 from eerovaher/no_legacypath
2 parents bad8fb7 + eee62ee commit f27a86e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pytest_mpl/plugin.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from urllib.request import urlopen
4242

4343
import pytest
44+
from packaging.version import Version
4445

4546
from pytest_mpl.summary.html import generate_summary_basic_html, generate_summary_html
4647

@@ -56,6 +57,8 @@
5657
Actual shape: {actual_shape}
5758
{actual_path}"""
5859

60+
PYTEST_LT_7 = Version(pytest.__version__) < Version("7.0.0")
61+
5962
# The following are the subsets of formats supported by the Matplotlib image
6063
# comparison machinery
6164
RASTER_IMAGE_FORMATS = ['png']
@@ -64,8 +67,8 @@
6467

6568

6669
def _get_item_dir(item):
67-
# .path is available starting from pytest 7, .fspath is for older versions.
68-
return getattr(item, "path", Path(item.fspath)).parent
70+
path = Path(item.fspath) if PYTEST_LT_7 else item.path
71+
return path.parent
6972

7073

7174
def _hash_file(in_stream):

0 commit comments

Comments
 (0)