Skip to content

Commit 65e76b7

Browse files
committed
pytest
1 parent a4c80eb commit 65e76b7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

nff/tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
22

33
import pytest
44
import torch
5+
import builtins
56

67
torch.set_num_threads(int(os.getenv("OMP_NUM_THREADS", "1")))
78

89

10+
def pytest_sessionstart(session):
11+
"""
12+
Pytorch 2.6 torch.load compatibility
13+
"""
14+
add_safe = getattr(torch.serialization, "add_safe_globals", None)
15+
if callable(add_safe):
16+
add_safe([builtins.slice])
17+
918
def pytest_addoption(parser):
1019
parser.addoption("--device", action="store", default="cpu", help="Whether to use the CPU or GPU for the tests")
1120

0 commit comments

Comments
 (0)