From 7ecb179a415e89b4c64db0713621fb4fc8531332 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 17 Oct 2026 01:36:41 +0000 Subject: [PATCH] Migrate stepper tests to the level-list representation Schedule test drives _pairs[i].explode/coalesce and patches _advance(index, buffer) for the stale L1->L2 feed mutant; remap rejection test patches _boundary_hosts entries and hierarchy.pairs instead of the read-only views; the GPU launch-failure test patches _pairs[0].explode. Assertions unchanged. Co-Authored-By: Claude Opus 5.5 --- .../test_refinement_three_level_multipatch.py | 23 ++++++++++--------- tests/unit/test_runtime_child_remap.py | 8 +++++-- .../multigrid/test_refinement_gpu.py | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/tests/unit/test_refinement_three_level_multipatch.py b/tests/unit/test_refinement_three_level_multipatch.py index e5068b4..3a79569 100644 --- a/tests/unit/test_refinement_three_level_multipatch.py +++ b/tests/unit/test_refinement_three_level_multipatch.py @@ -251,14 +251,14 @@ class ConstructorAndSchedule(unittest.TestCase): initial_c=c.current def record(name): return lambda source,*a,**kw: events.append((name,source)) - run._explode.side_effect=record('explode01') - run._child.explode.side_effect=record('explode12') + run._pairs[0].explode.side_effect=record('explode01') + run._pairs[1].explode.side_effect=record('explode12') for i,level in enumerate(run._levels): level.kernel.side_effect=record(f'step{i}') if bodies: g.boundary.kernel.side_effect=record('bfl2') - run._child.coalesce.side_effect=lambda src,dst,*a,**kw: events.append(('restrict21',dst)) - run._coalesce.side_effect=lambda src,dst,*a,**kw: events.append(('restrict10',dst)) + run._pairs[1].coalesce.side_effect=lambda src,dst,*a,**kw: events.append(('restrict21',dst)) + run._pairs[0].coalesce.side_effect=lambda src,dst,*a,**kw: events.append(('restrict10',dst)) run._status='ready' expected=[('explode01',initial_c)] for middle in (f.current,f.spare): @@ -278,13 +278,14 @@ class ConstructorAndSchedule(unittest.TestCase): self.assertEqual([l.kernel.call_count for l in run._levels],[1,2,4]) # A stale-feed implementation must fail the source-identity guard. feeds=[] - advance=run._advance_child - def checked_advance(buffer, **kw): - self.assertIs(buffer,(f.current,f.spare)[len(feeds)]) - feeds.append(buffer) - advance(buffer,**kw) - with patch.object(run,'_advance_child',side_effect=lambda buffer,**kw: - checked_advance(f.current,**kw)): + advance=run._advance + def checked_advance(index, buffer, **kw): + if index == 2: # L1 -> L2 feed: must be the L1 hop source + self.assertIs(buffer,(f.current,f.spare)[len(feeds)]) + feeds.append(buffer) + advance(index,buffer,**kw) + with patch.object(run,'_advance',side_effect=lambda index,buffer,**kw: + checked_advance(index,f.current if index == 2 else buffer,**kw)): with self.assertRaises(AssertionError): run.step() # A per-region shared-parent advance must fail the 1:2:4 guard. diff --git a/tests/unit/test_runtime_child_remap.py b/tests/unit/test_runtime_child_remap.py index 07d46be..384ebfc 100644 --- a/tests/unit/test_runtime_child_remap.py +++ b/tests/unit/test_runtime_child_remap.py @@ -1,4 +1,5 @@ """CPU mocks execute production remap lifecycle; no GPU numerical claim.""" +from dataclasses import replace import unittest from unittest.mock import patch @@ -68,8 +69,11 @@ class RuntimeChildRemap(unittest.TestCase): run._status = 'ready' for bad in ([], [(40,16,48,40)], [(16,16,32,24),(16,27,32,40)]): with self.assertRaises(ValueError): run.remap_child(bad) - for attribute, value in (('_wall_aware', True), ('child_boundary', object()), - ('fine_boundary', object()), ('child_patch', None)): + hosts, pairs = run._boundary_hosts, run.hierarchy.pairs + for attribute, value in (('_wall_aware', True), + ('_boundary_hosts', [*hosts[:2], object()]), # child boundary + ('_boundary_hosts', [hosts[0], object(), hosts[2]]), # fine boundary + ('hierarchy', replace(run.hierarchy, pairs=(pairs[0], None)))): with patch.object(run, attribute, value): with self.assertRaises(ValueError): run.remap_child(B) self.assertEqual(len(allocations), start) diff --git a/tests/validation/multigrid/test_refinement_gpu.py b/tests/validation/multigrid/test_refinement_gpu.py index 924b8ba..fac88c0 100644 --- a/tests/validation/multigrid/test_refinement_gpu.py +++ b/tests/validation/multigrid/test_refinement_gpu.py @@ -194,7 +194,7 @@ class CoupledGPU(unittest.TestCase): f"max_corner_packet={max_corner:.9g}; ownership/counts PASS", flush=True) # Fail before any additional time step; no stale synchronized export. - with patch.object(backend, "_explode", side_effect=RuntimeError("injected launch failure")): + with patch.object(backend._pairs[0], "explode", side_effect=RuntimeError("injected launch failure")): with self.assertRaisesRegex(RuntimeError, "injected"): backend.step() with self.assertRaisesRegex(RuntimeError, "failed"):