1010from pathlib import Path
1111
1212import pytest
13+ from flaky import flaky
1314
1415from modflow_devtools .models import (
1516 _DEFAULT_CACHE ,
@@ -231,6 +232,7 @@ def test_get_registry_cache_dir(self):
231232class TestDiscovery :
232233 """Test registry discovery."""
233234
235+ @flaky (max_runs = 3 , min_passes = 1 )
234236 def test_discover_registry (self ):
235237 """Test discovering registry for test repo."""
236238 # Use test repo/ref from environment
@@ -248,6 +250,7 @@ def test_discover_registry(self):
248250 assert discovered .mode == "version_controlled"
249251 assert isinstance (discovered .registry , ModelRegistry )
250252
253+ @flaky (max_runs = 3 , min_passes = 1 )
251254 def test_discover_registry_nonexistent_ref (self ):
252255 """Test that discovery fails gracefully for nonexistent ref."""
253256 source = ModelSourceRepo (
@@ -264,6 +267,7 @@ def test_discover_registry_nonexistent_ref(self):
264267class TestSync :
265268 """Test registry synchronization."""
266269
270+ @flaky (max_runs = 3 , min_passes = 1 )
267271 def test_sync_single_source_single_ref (self ):
268272 """Test syncing a single source/ref."""
269273 _DEFAULT_CACHE .clear (source = TEST_MODELS_SOURCE_NAME , ref = TEST_MODELS_REF )
@@ -280,6 +284,7 @@ def test_sync_single_source_single_ref(self):
280284 assert len (result .failed ) == 0
281285 assert (TEST_MODELS_SOURCE_NAME , TEST_MODELS_REF ) in result .synced
282286
287+ @flaky (max_runs = 3 , min_passes = 1 )
283288 def test_sync_creates_cache (self ):
284289 """Test that sync creates cached registry."""
285290 _DEFAULT_CACHE .clear (source = TEST_MODELS_SOURCE_NAME , ref = TEST_MODELS_REF )
@@ -293,6 +298,7 @@ def test_sync_creates_cache(self):
293298 source .sync (ref = TEST_MODELS_REF )
294299 assert _DEFAULT_CACHE .has (TEST_MODELS_SOURCE_NAME , TEST_MODELS_REF )
295300
301+ @flaky (max_runs = 3 , min_passes = 1 )
296302 def test_sync_skip_cached (self ):
297303 """Test that sync skips already-cached registries."""
298304 _DEFAULT_CACHE .clear (source = TEST_MODELS_SOURCE_NAME , ref = TEST_MODELS_REF )
@@ -312,6 +318,7 @@ def test_sync_skip_cached(self):
312318 assert len (result2 .synced ) == 0
313319 assert len (result2 .skipped ) == 1
314320
321+ @flaky (max_runs = 3 , min_passes = 1 )
315322 def test_sync_force (self ):
316323 """Test that force flag re-syncs cached registries."""
317324 _DEFAULT_CACHE .clear (source = TEST_MODELS_SOURCE_NAME , ref = TEST_MODELS_REF )
@@ -331,6 +338,7 @@ def test_sync_force(self):
331338 assert len (result .synced ) == 1
332339 assert len (result .skipped ) == 0
333340
341+ @flaky (max_runs = 3 , min_passes = 1 )
334342 def test_sync_via_source_method (self ):
335343 """Test syncing via ModelSourceRepo.sync() method."""
336344 _DEFAULT_CACHE .clear (source = TEST_MODELS_SOURCE_NAME , ref = TEST_MODELS_REF )
@@ -348,6 +356,7 @@ def test_sync_via_source_method(self):
348356 assert len (result .synced ) == 1
349357 assert (TEST_MODELS_SOURCE_NAME , TEST_MODELS_REF ) in result .synced
350358
359+ @flaky (max_runs = 3 , min_passes = 1 )
351360 def test_source_is_synced_method (self ):
352361 """Test ModelSourceRepo.is_synced() method."""
353362 _DEFAULT_CACHE .clear (source = TEST_MODELS_SOURCE_NAME , ref = TEST_MODELS_REF )
@@ -362,6 +371,7 @@ def test_source_is_synced_method(self):
362371 source .sync (ref = TEST_MODELS_REF )
363372 assert source .is_synced (TEST_MODELS_REF )
364373
374+ @flaky (max_runs = 3 , min_passes = 1 )
365375 def test_source_list_synced_refs_method (self ):
366376 """Test ModelSourceRepo.list_synced_refs() method."""
367377 _DEFAULT_CACHE .clear (source = TEST_MODELS_SOURCE_NAME , ref = TEST_MODELS_REF )
@@ -509,6 +519,7 @@ def test_cli_clear(self, capsys):
509519class TestIntegration :
510520 """Integration tests for full workflows."""
511521
522+ @flaky (max_runs = 3 , min_passes = 1 )
512523 def test_full_workflow (self ):
513524 """Test complete workflow: discover -> cache -> load."""
514525 _DEFAULT_CACHE .clear (source = TEST_MODELS_SOURCE_NAME , ref = TEST_MODELS_REF )
@@ -531,6 +542,7 @@ def test_full_workflow(self):
531542 assert loaded is not None
532543 assert len (loaded .models ) == len (discovered .registry .models )
533544
545+ @flaky (max_runs = 3 , min_passes = 1 )
534546 def test_sync_and_list_models (self ):
535547 """Test syncing and listing available models."""
536548 _DEFAULT_CACHE .clear (source = TEST_MODELS_SOURCE_NAME , ref = TEST_MODELS_REF )
0 commit comments