Skip to content

Commit ccf50c2

Browse files
committed
updated pytest compat
1 parent d83d8d1 commit ccf50c2

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

tests/client/contribs/conftest.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
1+
import pytest
2+
from packaging.version import Version
3+
14
try:
25
from mp_api.client.contribs import ContribsClient
36
except ImportError:
47
ContribsClient = None
58

69

7-
def pytest_ignore_collect(path, config):
8-
# Skip tests if contribs client isn't installed
9-
if ContribsClient is None and "contribs" in str(path):
10-
return True
11-
return False
10+
_pytest_version = Version(pytest.__version__)
11+
PYTEST_GE_8_0 = any(
12+
[
13+
_pytest_version.is_devrelease,
14+
_pytest_version.is_prerelease,
15+
_pytest_version >= Version("8.0"),
16+
]
17+
)
18+
19+
20+
if PYTEST_GE_8_0:
21+
22+
def pytest_ignore_collect(collection_path, config):
23+
# Skip tests if contribs client isn't installed
24+
if ContribsClient is None and "contribs" in str(collection_path):
25+
return True
26+
return False
27+
28+
else:
29+
30+
def pytest_ignore_collect(path, config):
31+
# Skip tests if contribs client isn't installed
32+
if ContribsClient is None and "contribs" in str(path):
33+
return True
34+
return False

0 commit comments

Comments
 (0)