We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 960894c + fc43e1c commit 1272d80Copy full SHA for 1272d80
torch_np/tests/conftest.py
@@ -1,3 +1,5 @@
1
+import sys
2
+
3
import pytest
4
5
@@ -7,6 +9,17 @@ def pytest_configure(config):
7
9
8
10
def pytest_addoption(parser):
11
parser.addoption("--runslow", action="store_true", help="run slow tests")
12
+ parser.addoption("--nonp", action="store_true", help="error when NumPy is accessed")
13
14
15
+def pytest_sessionstart(session):
16
+ if session.config.getoption("--nonp"):
17
18
+ class Inaccessible:
19
+ def __getattribute__(self, attr):
20
+ raise RuntimeError(f"Using --nonp but accessed np.{attr}")
21
22
+ sys.modules["numpy"] = Inaccessible()
23
24
25
def pytest_collection_modifyitems(config, items):
0 commit comments