From f964ff347c234da803548e6ed4bc9310a17a5287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E7=99=BD=E5=8F=94?= <11794527+absfan@user.noreply.gitee.com> Date: Tue, 17 Nov 2026 02:24:32 +0800 Subject: [PATCH] test: align native lifecycle fixtures with validated source identities --- tests/support/async_add_lifecycle_fixture.py | 2 +- tests/test_import_without_export_gate.py | 6 +++--- tests/test_review430.py | 7 ++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/support/async_add_lifecycle_fixture.py b/tests/support/async_add_lifecycle_fixture.py index 467f4d2..7b45119 100644 --- a/tests/support/async_add_lifecycle_fixture.py +++ b/tests/support/async_add_lifecycle_fixture.py @@ -64,7 +64,7 @@ while not (root/'lm-exit').exists(): time.sleep(.02) patch.setattr(win32gui, 'EnumChildWindows', lambda h, fn, arg: fn(301, arg) if h == 300 and mode == 'acknowledged' else None) # Only the external native text-control setter is substituted. - patch.setattr(native, '_set_probe_field', lambda *args: None) + patch.setattr(native, '_set_probe_field', lambda hwnd, control, value, root, *, read_only=False: None) def post(hwnd, *args): if hwnd == 110: state['new'] = True if hwnd == 210: diff --git a/tests/test_import_without_export_gate.py b/tests/test_import_without_export_gate.py index c972de6..ae1631d 100644 --- a/tests/test_import_without_export_gate.py +++ b/tests/test_import_without_export_gate.py @@ -97,7 +97,7 @@ def test_native_project_normalization_is_a_recorded_difference_not_import_failur def worker(adapter, job, evidence): result = original_worker(adapter, job, evidence) if job['operation'] == 'add' and result.get('success'): - project = request.library.parent/'ReusableBlocksLP/Block/Work/Source.prj' + project = request.library.parent/'ReusableBlocksLP/Block/Work/Block.prj' with project.open('a') as stream: stream.write('SECTION VBPCBIndicators\nKEY VBPCBForwardAnno "0"\nKEY CADBackAnno "0"\nENDSECTION\n') return result @@ -106,7 +106,7 @@ def test_native_project_normalization_is_a_recorded_difference_not_import_failur assert result.status == 'UPLOADED' and result.safe_to_continue, result.detail comparison = json.loads((result.evidence_path.parent/'add/identity-comparison.json').read_text()) assert comparison['identity_matches'] and not comparison['assets_match'] - assert 'Source.prj' in comparison['asset_differences']['modified'] + assert 'Block.prj' in comparison['asset_differences']['modified'] @pytest.mark.parametrize('registered_top,expected', [('Block', 'UPLOADED'), ('Foreign', 'RECOVERY_REQUIRED')]) @@ -117,7 +117,7 @@ def test_native_top_block_may_match_registration_name_but_not_an_unrelated_name( def worker(adapter, job, evidence): result = original_worker(adapter, job, evidence) if job['operation'] == 'add' and result.get('success'): - project = request.library.parent/'ReusableBlocksLP/Block/Work/Source.prj' + project = request.library.parent/'ReusableBlocksLP/Block/Work/Block.prj' project.write_text(project.read_text().replace('KEY RootBlock "Top"', f'KEY RootBlock "{registered_top}"')) return result monkeypatch.setattr(native.NativeManagementAdapter, '_worker', worker) diff --git a/tests/test_review430.py b/tests/test_review430.py index 60ec62a..c9d382a 100644 --- a/tests/test_review430.py +++ b/tests/test_review430.py @@ -109,7 +109,12 @@ def test_real_file_error_preserves_failed_item_and_allows_an_independent_item(tr return assets(source, expected_library) monkeypatch.setattr(identity, 'asset_identity', read_assets) adapter = _OwnedFixtureManagementAdapter(root, 'owned') - results = run_management_batch([request, replace(request, name='Other')], adapter=adapter, + from test_management import project + other_source = project(request.source.parent.parent/'other-source', name='Other') + for path in (other_source, other_source.parent/'PCB/pcb.prj'): + with path.open('a') as stream: + stream.write(f'KEY CentralLibrary "{request.library}"\n') + results = run_management_batch([request, replace(request, name='Other', source=other_source)], adapter=adapter, idle_check=lambda *_: None) assert [r.status for r in results] == ['RECOVERY_REQUIRED', 'UPLOADED'] assert all(r.safe_to_continue for r in results)