Skip to content

Commit d64831b

Browse files
RobotSailclaude
andcommitted
fix test: prevent MagicMock auto-creating VLM attributes
Use spec=[] on mock model.model to prevent hasattr from falsely detecting language_model attribute in wrap_fsdp2 tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c28190a commit d64831b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/test_model_initialization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ def mock_model(self):
109109
model.config = MagicMock()
110110
model.config.use_cache = True
111111

112-
# Mock transformer layers
112+
# Mock transformer layers (standard CausalLM structure: model.model.layers)
113113
layers = [MagicMock() for _ in range(4)]
114-
model.model = MagicMock()
114+
model.model = MagicMock(spec=[]) # spec=[] prevents auto-creating attributes
115115
model.model.layers = layers
116116

117117
return model

0 commit comments

Comments
 (0)