Skip to content

Commit 0ba2cfa

Browse files
Merge pull request #5187 from neutrinoceros/tst/compat-pytest-8.5
TST/BUG: fix an incoming incompatibility with pytest 8.5 in our test framework
2 parents 88952d8 + 9d22500 commit 0ba2cfa

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

yt/testing.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,15 @@ def skip(reason: str):
12451245
def dec(func):
12461246
@wraps(func)
12471247
def wrapper(*args, **kwargs):
1248-
raise SkipTest(reason)
1248+
if os.getenv("PYTEST_VERSION") is not None:
1249+
# this is the recommended way to detect a pytest session
1250+
# https://docs.pytest.org/en/stable/reference/reference.html#envvar-PYTEST_VERSION
1251+
import pytest
1252+
1253+
pytest.skip(reason)
1254+
else:
1255+
# running from nose, or unittest
1256+
raise SkipTest(reason)
12491257

12501258
return wrapper
12511259

0 commit comments

Comments
 (0)