Skip to content

Commit 58ff79e

Browse files
committed
use stack inspection for pytest as well
This would catch it during test collections as well.
1 parent bbc2229 commit 58ff79e

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

discretize/tests.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
assert_isadjoint
2626
""" # NOQA D205
2727

28-
import os
2928
import warnings
3029

3130
import numpy as np
@@ -85,10 +84,9 @@
8584

8685

8786
def _warn_random_test():
88-
in_pytest = "PYTEST_CURRENT_TEST" in os.environ
89-
in_nosetest = any(
90-
x[0].f_globals["__name__"].startswith("nose.") for x in inspect.stack()
91-
)
87+
stack = inspect.stack()
88+
in_pytest = any(x[0].f_globals["__name__"].startswith("_pytest.") for x in stack)
89+
in_nosetest = any(x[0].f_globals["__name__"].startswith("nose.") for x in stack)
9290

9391
if in_pytest or in_nosetest:
9492
test = "pytest" if in_pytest else "nosetest"

0 commit comments

Comments
 (0)