Skip to content

Commit ebfad63

Browse files
committed
tests(compat): stub torch module in conftest
Add tests/compat/conftest.py to inject a stub torch module into sys.modules when torch is not installed. This prevents ImportError during DLCLive compatibility tests so the API can be validated without requiring torch to be installed. This is a pragmatic workaround and includes a note to remove or replace it once imports are properly guarded in the package.
1 parent fd17969 commit ebfad63

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/compat/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# tests/compat/conftest.py
2+
import sys
3+
import types
4+
5+
# Stub out torch imports to avoid ImportError when torch is not installed in DLCLive package.
6+
# This allows testing of DLCLive API compatibility without requiring torch.
7+
# Ideally imports should be guarded in the package itself, but this is a pragmatic solution for now.
8+
# IMPORTANT NOTE: This should ideally be removed and replaced whenever possible.
9+
if "torch" not in sys.modules:
10+
sys.modules["torch"] = types.ModuleType("torch")

0 commit comments

Comments
 (0)