Skip to content

Commit f2ee5a7

Browse files
robtaylorclaude
andcommitted
Fix test_pin_lock.py to use actual _QuadPackageDef instead of mock
Replaced MockPackageType with actual _QuadPackageDef instances in tests to fix validation errors with Pydantic discriminated unions. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 627178d commit f2ee5a7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/test_pin_lock.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class MockPackageType:
2121
"""Mock for package type class used in tests"""
2222
def __init__(self, name="test_package"):
2323
self.name = name
24-
self.type = "_QuadPackageDef" # This is needed for Pydantic discrimination
24+
self.type = "_PGAPackageDef" # This is needed for Pydantic discrimination
2525
self.pins = set([str(i) for i in range(1, 100)]) # Create pins 1-99
2626
self.width = 50 # For Pydantic compatibility
2727
self.height = 50 # For Pydantic compatibility
@@ -262,7 +262,7 @@ def test_allocate_pins_port(self):
262262

263263
@mock.patch("chipflow_lib.pin_lock._parse_config")
264264
@mock.patch("chipflow_lib.pin_lock.Config.model_validate")
265-
@mock.patch("chipflow_lib.pin_lock.PACKAGE_DEFINITIONS", new={"cf20": MockPackageType(name="cf20")})
265+
@mock.patch("chipflow_lib.pin_lock.PACKAGE_DEFINITIONS", new={"cf20": _QuadPackageDef(name="cf20", width=50, height=50)})
266266
@mock.patch("chipflow_lib.pin_lock.top_interfaces")
267267
@mock.patch("pathlib.Path.exists")
268268
@mock.patch("builtins.open", new_callable=mock.mock_open)
@@ -294,7 +294,7 @@ def test_lock_pins_new_file(self, mock_open, mock_exists, mock_top_interfaces,
294294

295295
@mock.patch("chipflow_lib.pin_lock._parse_config")
296296
@mock.patch("chipflow_lib.pin_lock.Config.model_validate")
297-
@mock.patch("chipflow_lib.pin_lock.PACKAGE_DEFINITIONS", new={"cf20": MockPackageType(name="cf20")})
297+
@mock.patch("chipflow_lib.pin_lock.PACKAGE_DEFINITIONS", new={"cf20": _QuadPackageDef(name="cf20", width=50, height=50)})
298298
@mock.patch("chipflow_lib.pin_lock.top_interfaces")
299299
@mock.patch("pathlib.Path.exists")
300300
@mock.patch("pathlib.Path.read_text")

0 commit comments

Comments
 (0)