fix: address PR review identity and snapshot safety gaps

This commit is contained in:
阿白叔 committed 2026-10-30 17:48:08 +08:00
1 parent 131b6dbbb3
commit f0a0131aac
15 files changed
+312 -64

No files matched your search

+22 -1
View File
@@ -14,7 +14,7 @@ FAKES = next(ast.literal_eval(statement.value) for statement in TREE.body
for target in statement.targets))
EXTRA = r'''
Class ValueComponent
Public UID, Refdes, Orientation, Scale, Attributes, AddCount
Public UID, Refdes, Orientation, Scale, Attributes, AddCount, Selected
Private Point
Private Sub Class_Initialize()
Set Point=New TestPoint
@@ -371,6 +371,27 @@ Require InStr(QPReadUtf8(QP_Fso.BuildPath(QP_Root,"status.tsv")),"saved_ok")>0,"
''', routines_transform=_batch_readback_fixture)
def test_missing_uid_capture_restore_save_and_reopen(tmp_path):
run_vbs(tmp_path, 'part_number', '''
Dim FullChecks, Captured
FullChecks=0
Command.Add "project_path",QPProjectPath()
Comp.FindAttribute("Part Number").Value="OLD"
QPCaptureAndSelect Command,SnapshotPath
Set Captured=QPReadSnapshot(SnapshotPath)
Require Captured.Item("components").Item("0")("uid")="@REFDES|R1","fallback lost in snapshot"
Require Captured.Item("untouched").Count=0,"target incorrectly captured as untouched"
Comp.FindAttribute("Part Number").Value="NEW"
QP_BatchMode=True:QP_SessionMode=False
QP_OwnedProject=True:QP_OwnedProjectPath=QPProjectPath()
QPRestoreAfterOperatorReplace Command,SnapshotPath
QPFinishBatchItem
Require QP_App.SaveCount=1,"replacement was not saved exactly once"
Require Len(QP_App.ProjectPath)=0,"reopened project was not closed"
Require InStr(QPReadUtf8(QP_Fso.BuildPath(QP_Root,"status.tsv")),"saved_ok")>0,"missing saved readback proof"
''', before='Comp.UID=""', routines_transform=_batch_readback_fixture)
def test_non_session_no_match_closes_without_any_save(tmp_path):
run_vbs(tmp_path, 'part_number', '''
Dim FullChecks